Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Separation of a text file

Status
Not open for further replies.

iara

Programmer
Oct 2, 2002
17
0
0
HN
Hi, Im quite new at C#, I would like to open a .txt file and read it and then separate the variables. How can I indicate the reader to just read some on the variables and skip others..I mean I want the reader to read word by word, I know I should use streamreader.
I also would like to ask what can be easier to store these variables in a database or to just use an array ?
Thanks in advance if someone would give them their opinion...
 
I would use the TextReader class for this, then split the file as required with the SubString method of the String Object. If you are concatenating strings make sure you're using the StringBuilder object because of the immutable/mutable difference.

Whether you store to a file system or not is up to you.. If I need to manipulate content quickly in memory I use the MemoryStream object.

Hope this helps.

Adrian
 
Hi,
I have read line by line and have search for a particular word using regex, when it has found this word i have sent this line to a function because i want to read this particular line by each character. My question is the file is in .rtf, how can y keep the format of this particular line? Its just sending a bunch of text characters.
well Is there a better way for me to do this ?
any suggestions?
 
Hi,
I have read a file line by line and have searched for a particular word using regex, when it has found this word i have sent this line to a function because i want to read this particular line by each character. My question is the file is in .rtf, how can y keep the format of this particular line? Its just sending a bunch of text characters.
what i am trying to do is to read a particular line ,word by word.
well Is there a better way for me to do this ?
any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top