Try your loop as

for(int i=1;i<len;i++)
{
        sw1.Write(System.Convert.ToChar(sr.Read())); // stream the interesting char
to the new file
        sr.Read(); // discard the other char
}

No need for buff or sb.

- Jim

-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of
Nischal Chitta
Sent: Friday, April 12, 2002 3:27 PM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] Reading a File


This happens quite often. You post a question, then everything seems to
work your way.

Following is something I did to achieve it with a small hiccup. Can someone
let me know how I can get a character array to be built as a string. In
essence

FileStream fs = new FileStream("C:\\First.txt",FileMode.Open);
StreamReader sr = new StreamReader(fs);
FileStream fs1 = new FileStream("C:\\Final.txt",FileMode.Create);
StreamWriter sw1 = new StreamWriter(fs1);
StringBuilder sb = new StringBuilder();
long len = fs.Length;
char[] buff = new char[2448];
for(int i=1;i<len;i++)
{
sr.Read(buff,i,2);
}
// Here somehow I need to get the buff into the fs1 using sw1. Can someone
let me know how I can get this buff to the fs1.
sr.Close();
fs.Close();
sw1.Close();
fs1.Close();

Thanks
Nischal

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to