J
j
I'm using a static class to read (from an XML file) some 'frequently
used' settings that will be shared in both console applications and
web services.
The class works for console applications, butn using the same class in
a web service always results in a FileNotFoundException.
I have verified that the file it needs is in the directory where it is
expecting it, but I still get the same exception.
I added the "HttpContext" line because I'd read somewhere that it was
preferable to "GetExecutingAssembly()" when dealing with web service,
but that didn't work, either.
What is the most reliable way to accomplish this?
FileInfo loc = new
FileInfo(Assembly.GetExecutingAssembly().Location);
FileInfo config = new
FileInfo(Path.Combine(loc.DirectoryName, file));
if (!config.Exists)
{
Logger.writeLog(config.FullName);
config = new
FileInfo(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath,
file));
if (!config.Exists)
{
Logger.writeLog(config.FullName);
throw new
FileNotFoundException(config.FullName);
}
}
_file = config.FullName;
thanks in advance.
used' settings that will be shared in both console applications and
web services.
The class works for console applications, butn using the same class in
a web service always results in a FileNotFoundException.
I have verified that the file it needs is in the directory where it is
expecting it, but I still get the same exception.
I added the "HttpContext" line because I'd read somewhere that it was
preferable to "GetExecutingAssembly()" when dealing with web service,
but that didn't work, either.
What is the most reliable way to accomplish this?
FileInfo loc = new
FileInfo(Assembly.GetExecutingAssembly().Location);
FileInfo config = new
FileInfo(Path.Combine(loc.DirectoryName, file));
if (!config.Exists)
{
Logger.writeLog(config.FullName);
config = new
FileInfo(Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath,
file));
if (!config.Exists)
{
Logger.writeLog(config.FullName);
throw new
FileNotFoundException(config.FullName);
}
}
_file = config.FullName;
thanks in advance.