T
tcomer
Hello! I've run into a problem and I can't seem to understand "why"
the problem occurs. In my program:
using System;
using System.IO;
using System.Xml;
namespace MyNamespace
{
class MainApp
{
[STAThread]
public static void Main(String[] args)
{
// Using instantiation to allow Main to access a non-
static function
MainApp app = new MainApp();
app.GetApplicationSettings();
}
private void GetApplicationSettings()
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load("filedoesntexist")
}
catch(System.IO.FileNotFoundException e)
{
// show stacktrace
}
}
}
}
When I try to load the file (which doesn't exist) the line
"xmlDoc.Load("filedoesntexist")" throws a FileNotFoundException. The
problem is, the exception falls through the function and back to Main,
where it isn't handled. Why does this happen? I'm still trying to
understand the inner workings of the .NET framework. Any help and/or
explanation is very much appreciated. Thanks
the problem occurs. In my program:
using System;
using System.IO;
using System.Xml;
namespace MyNamespace
{
class MainApp
{
[STAThread]
public static void Main(String[] args)
{
// Using instantiation to allow Main to access a non-
static function
MainApp app = new MainApp();
app.GetApplicationSettings();
}
private void GetApplicationSettings()
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load("filedoesntexist")
}
catch(System.IO.FileNotFoundException e)
{
// show stacktrace
}
}
}
}
When I try to load the file (which doesn't exist) the line
"xmlDoc.Load("filedoesntexist")" throws a FileNotFoundException. The
problem is, the exception falls through the function and back to Main,
where it isn't handled. Why does this happen? I'm still trying to
understand the inner workings of the .NET framework. Any help and/or
explanation is very much appreciated. Thanks