Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:
C#
 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
Updated 24-Jul-12 8:35am
v2
Comments
[no name] 24-Jul-12 14:19pm    
Anything wrong in string.Replace("||", "|Null|"); ?
Member 8714829 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.
[no name] 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900