Hi,

I have used stream reader to read text file using Readline method, and i tried to append all string to string builder, but i'm not able to get all string value, i'm only getting last line of file, i have used the following coding

StreamReader reader = new StreamReader(@"d:\web_extract.txt",Encoding.Default);
StringBuilder strbuild = null;
StreamWriter writer = null;
while(reader.Peek() >= 0)
{
string str = null;
str = reader.ReadLine().ToString();
str = str.Replace("Ú"," ");
strbuild = new StringBuilder();
// str = strbuild.Replace("Ú"," ").ToString();
strbuild.Append(str);


}
string str1 = strbuild.ToString();
reader.Close();
writer = new StreamWriter(@"d:\web_extract1.txt",true);
writer.Write(str1);
writer.Close();

Please anybody help to solve this problem, advanced thanks for any reply.

Thanks.

This is because you instantiate the stringbuilder object via

strbuild = new StringBuilder();

in the loop, you have to instantiate it outside when you first declare it

StreamReader reader = new StreamReader(@"d:\web_extract.txt",Encoding.Default);
StringBuilder strbuild = new StringBuilder(); <--here