N
NonNB
Hi
We have a utility assembly which can be used by both ASPNET and
WinForm apps.
The utility needs to retrieve XML files from a path relative to the
respective installations
(i.e. C:\Program Files\SomeApp\Data\.. and WebApp\App_Data\... for
ASPNET)
Does someone have some some standard code to detect and map the
respective paths in an agnostic manner?
Something like
// Pseudo Code
if (AppDomain.CurrentDomain.IsASPNET())
{
// Called from Web Page
return HttpContext.Current.Server.MapPath(fileName);
}
else
{
// Called from Web Page
return Path.GetDirectoryName
(Assembly.GetExecutingAssembly().Location) + fileName;
}
Thanks in advance!
Stuart
We have a utility assembly which can be used by both ASPNET and
WinForm apps.
The utility needs to retrieve XML files from a path relative to the
respective installations
(i.e. C:\Program Files\SomeApp\Data\.. and WebApp\App_Data\... for
ASPNET)
Does someone have some some standard code to detect and map the
respective paths in an agnostic manner?
Something like
// Pseudo Code
if (AppDomain.CurrentDomain.IsASPNET())
{
// Called from Web Page
return HttpContext.Current.Server.MapPath(fileName);
}
else
{
// Called from Web Page
return Path.GetDirectoryName
(Assembly.GetExecutingAssembly().Location) + fileName;
}
Thanks in advance!
Stuart