Hey I'm really new to C# - I don't understand how to properly sort out the code based on the messages that I am getting.
The messages are:
} expected
{ expected
) expected
Invalid expression term '}'
When I simply enter these characters into the place that the debugger tells me to, more errors pop up - I am using Visual Studio 2008. This is the section of code I believe I am having difficulty with:
{
try
{
using(FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read)
{
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
using (StreamWriter sw = new StreamWriter("TestFile.txt"))
{
sw.Write("\n");
sw.WriteLine("line\n");
sw.WriteLine("test");
}
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
Console.WriteLine("File: " + e.Name);
Console.WriteLine("Folder:" + Path.GetDirectoryName(e.FullPath));
Console.WriteLine(d.Message);
continue;
}
}
}
}
THANKS FOR ANY HELP!