Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Anyone knows how to parse out a text file line by line and when two pipe signs found to be adjacent to each other then the program would place a string (for example the qord Null) in between. I am using the following code to pen and read the text file to begin with:
 using (StreamReader readFile = new StreamReader(tmpFilename.FullName.ToString()))
{
string line = null;
    while ((line = readFile.ReadLine()) != null)
              {
             // Code here....process out certain fields in each line }
}
 
Need to know the best appraoch to do so without impacting performance. Thanks.
Posted 24-Jul-12 8:30am
Edited 24-Jul-12 9:35am
(no name)46.1K
v2
Comments
Wes Aday at 24-Jul-12 14:19pm
   
Anything wrong in string.Replace("||", "|Null|"); ?
Member 8714829 at 24-Jul-12 15:20pm
   
That works I've also thought about it but wondered if it would impact performance (having to replace any occurance within each line! I will try it, many thanks.
Wes Aday at 24-Jul-12 20:12pm
   
The string replacement will probably be a negligible performance impact compared to the reading of the file from disk.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 24 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100