C
Carlos
Dear All,
I have written a very simple class with the following constuctor. The
project is a PPC project. When the line comes to "using (...)", it
immediately jumps to the "catch" clause without knowing the reason. I have
tried different code, but I just can write a file, but not open the open for
read. Can anyone give me some help?
Regards,
Carlos
try
{
// if ( File.Exists(fileName) )
// File.Delete(fileName);
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader(fileName))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
u.Items.Add(line);
}
}
}
catch ( Exception e )
{
MessageBox.Show(e.Message);
}
I have written a very simple class with the following constuctor. The
project is a PPC project. When the line comes to "using (...)", it
immediately jumps to the "catch" clause without knowing the reason. I have
tried different code, but I just can write a file, but not open the open for
read. Can anyone give me some help?
Regards,
Carlos
try
{
// if ( File.Exists(fileName) )
// File.Delete(fileName);
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader(fileName))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
u.Items.Add(line);
}
}
}
catch ( Exception e )
{
MessageBox.Show(e.Message);
}