Quantcast
Channel: Strange Exception
Viewing all articles
Browse latest Browse all 4

Strange Exception

$
0
0
I'm reading from a text file using System.IO.StreamReader, like so

so the code button isnt doing anything but here is the code:

string path = AppConfigDirectory + "\\config.ini";
if (!Directory.Exists(AppConfigDirectory))
{
      Directory.CreateDirectory(AppConfigDirectory);

}
StreamReader xin = new StreamReader(path);



while (!xin.EndOfStream)    //<-- Exception thrown here!
{
//some stuff

}

xin.Close();

Everytime it runs, an ObjectDisposedException is thrown when the loop starts. It wil skip over any breakpoints I put in between
the start of the method and where the exception is thrown. When I step through the code everything works as expected. I'm 
stumped, since obviously the stream souldn't be closed or disposed yet. Is this a bug or is there something that I'm missing? 




Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images