can anyone tell me how to read from a text file, line by line....
may be this will help you a lil bit.
may be this will help you a lil bit. http://msdn.microsoft.com/en-us/library/aa287535(VS.71).aspx
thanks....this helped, par i have another problem, i need to search for a string in a line and replace it, do u have a code for this in c#.
You need to put all your content in a string and then replace what you need a and rewrite the text file with a StreamWriter.
StreamReader sr = null;
FileStream file = null;
string fileData = String.Empty;
file = new FileStream("test.txt", FileMode.Open, FileAccess.Read);
sr = new StreamReader(file, Encoding.UTF8);
string outputData = String.Empty;
string temp = String.Empty;
temp = sr.ReadLine();
if (temp != null)
temp = temp.Replace("the", "THE");
outputData += temp + "\n";
catch (Exception ex)
Console.WriteLine("An error occurred: " + ex.Message);
if (sr != null)
if (file != null)
You can also use the method ReadToEnd to read everything to one string and then use String.Replace method.
Depending on what you want to do you can also consider using regular expressions.
Hi all! I need help understanding what my teacher expects from this project.
Here is the link to the instructions for the project: http://cs.ecu.edu/~karl/2530/spr18/Assn/Assn5/assn5.html
I wrote a little bit of ...
Anyone have a shell script to remove controlM character from all the files in a directory
Define a class named Pair where the data(state) part contains two double-typed
numbers, num1 and num2. The method(behaviour) part contain the following methods:
o getSum() – returns the result of ...