I have a text file which has content similar to one shown below. I used to a StremReader to read the header and then read the ASCII content. For some reason, it doesnt read till the end of the stream and returns -1. ReadLine also returns null. The problem is worse if the ascii content exceeds the default buffer size of 4096. I figured that using a BufferedStream would help since it caches the data and it indeed reads the whole ascii content which the streamreader couldnt. My problem is how to read the header with BufferedStream class since i couldnt find a member function which could return a string and then I could parse it to read the header.
/* C# code */
FileStream fs=new FileStream(fname,
//Open the file
StreamReader sr = new StreamReader(fs);
ReadHeader();//uses streamreader class
//Read the Ascii content
/* Doesnt work
while(sr.Peek() > -1)
/* Doesnt work either
Pass the BufferedStream instead of the FileStream to the StreamReader.
BufferedStream bs=new BufferedStream(fs);
StreamReader sr = new StreamReader(bs);
Read the header using StreadReader and use the offset so that you can use BuffereStream bs.Read(offset,buf,buffersize);
Hope this helps others who had a similar problem.