Is this OK? (.Net 4.5)
try
{
StreamReader sr = = new StreamReader(ValidFilePathName);
line = file.ReadLine();
While (line != null)
{
line = file.ReadLine();
}
sr.Close();
}
catch
{
// blah Do nothing
}
I feel like there is something wrong with my pattern here. My concern is that when there is a file exception, does the stream get closed properly? I was taught to use using to set the stream, but Code Analysis tool does not like it. Perhaps there is something else. It seems to read the file OK, but I remember needing to use File stream and stream reader in the past... Was there a good reason for combining the two?
finally
block. Why does your code analysis tool not like theusing
statement? \$\endgroup\$