Quote:
StreamReader sr = new StreamReader(@"i:\tyj.txt");
This line is causing an error to be thrown. This stops your code before you get to the line where your message box is.
-- add--
It could not find the file. Either the drive I:\ wasn't found, or the file wasn't there on the root of I:\. When you throw an error, think of it as crashing. Your code crashed, and never made it to the message boxes you were intending to display.
------------
When you hit an error in code, it exits there and "throws an exception". This means, the rest of your code does not get executed. You can do try catch, or surround it in logic to make sure you protect against the error.
You can wrap it in a try catch
try
{
StreamReader sr = new StreamReader("...");
}
catch(FileNotFoundException e)
{
}
or you can do it much easier with:
if(File.Exists("..."))
{
}
else
{
}