Click here to Skip to main content
15,913,486 members
Home / Discussions / C#
   

C#

 
GeneralRe: Calculate How Many Mondays in a Particular Month Pin
cdpace18-Nov-09 10:49
cdpace18-Nov-09 10:49 
Questionreading text file as a database Pin
Member 473702218-Nov-09 4:54
Member 473702218-Nov-09 4:54 
AnswerRe: reading text file as a database Pin
Richard MacCutchan18-Nov-09 5:05
mveRichard MacCutchan18-Nov-09 5:05 
AnswerRe: reading text file as a database Pin
TheDudeJuan18-Nov-09 5:06
TheDudeJuan18-Nov-09 5:06 
AnswerRe: reading text file as a database Pin
EliottA18-Nov-09 5:12
EliottA18-Nov-09 5:12 
GeneralRe: reading text file as a database Pin
TheDudeJuan18-Nov-09 5:17
TheDudeJuan18-Nov-09 5:17 
GeneralRe: reading text file as a database Pin
EliottA18-Nov-09 5:19
EliottA18-Nov-09 5:19 
AnswerRe: reading text file as a database Pin
Nuri Ismail18-Nov-09 5:16
Nuri Ismail18-Nov-09 5:16 
You can use StreamReader[^] class to read the file line by line.
If your fields are with fixed lengths you can use the String.Substring[^] method to extract the fields from the line. Here is an example:

string filePath = @"Path_to_your_file_here";
string line;

// Field lengths (I use the lengths from your original post):
int idLength = 5, snLength = 13, amountLength = 15, blankLength = 15;
 
if (File.Exists(filePath))
{
	StreamReader file = null;
	try
	{
		file = new StreamReader(filePath);
		while ((line = file.ReadLine()) != null)
		{
			// Extract fields from the line
                        string id = line.Substring(0, idLength);
			string sn = line.Substring(idLength, snLength);
			string amount = line.Substring(idLength + snLength, amountLength);
			string blank = line.Substring(idLength + snLength + amountLength, blankLength);
		}
	}
	finally
	{
		if (file != null)
		file.Close();
	}
} 


I hope this helps. Smile | :)

Regards,
Nuri Ismail
GeneralRe: reading text file as a database Pin
Member 473702218-Nov-09 7:42
Member 473702218-Nov-09 7:42 
GeneralRe: reading text file as a database Pin
Nuri Ismail18-Nov-09 21:09
Nuri Ismail18-Nov-09 21:09 
AnswerRe: reading text file as a database Pin
SilimSayo18-Nov-09 5:33
SilimSayo18-Nov-09 5:33 
AnswerRe: reading text file as a database Pin
PIEBALDconsult18-Nov-09 6:13
mvePIEBALDconsult18-Nov-09 6:13 
GeneralRe: reading text file as a database Pin
Member 473702218-Nov-09 7:17
Member 473702218-Nov-09 7:17 
GeneralRe: reading text file as a database Pin
PIEBALDconsult18-Nov-09 12:07
mvePIEBALDconsult18-Nov-09 12:07 
QuestionGet all users from a group in ad using directorysearcher Pin
caiena18-Nov-09 4:11
caiena18-Nov-09 4:11 
QuestionI did a project on windows in c #.net and when i opened the project after some days it is showing "Could not find type 'CrystalDecisions.Windows.Forms.CrystalReportViewer'. Please make sure that the assembly that contains this type is referenced. If Pin
praveenkumar_vittaboina18-Nov-09 3:35
praveenkumar_vittaboina18-Nov-09 3:35 
AnswerRe: I did a project on windows... Pin
OriginalGriff18-Nov-09 3:55
mveOriginalGriff18-Nov-09 3:55 
Answer. Pin
musefan18-Nov-09 3:56
musefan18-Nov-09 3:56 
AnswerRe: I did a project on windows in c #.net and when i opened the project after some days it is showing "Could not find type 'CrystalDecisions.Windows.Forms.CrystalReportViewer'. Please make sure that the assembly that contains this type is referenced. Pin
Abhishek Sur18-Nov-09 4:48
professionalAbhishek Sur18-Nov-09 4:48 
Questionmultiple webcam capture Pin
mehrdad33318-Nov-09 3:32
mehrdad33318-Nov-09 3:32 
AnswerRe: multiple webcam capture Pin
Richard MacCutchan18-Nov-09 5:09
mveRichard MacCutchan18-Nov-09 5:09 
QuestionSQLite Pin
jashimu18-Nov-09 2:41
jashimu18-Nov-09 2:41 
AnswerRe: SQLite Pin
Eduard Keilholz18-Nov-09 2:45
Eduard Keilholz18-Nov-09 2:45 
GeneralRe: SQLite Pin
jashimu18-Nov-09 2:50
jashimu18-Nov-09 2:50 
GeneralRe: SQLite Pin
Eduard Keilholz18-Nov-09 3:02
Eduard Keilholz18-Nov-09 3:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.