G
Guest
How can I retrieve web application name (or virtual dir name)?
(Actually I need physical root directory of web application)
I want to open some files in web application root relative
directory.
Previously I used to open the files when client connected and
thus could use the following code to retreive physical file location:
string webAppRootDir = Server.MapPath(Request.ApplicationPath);
Now I would like to open the files in application startup routine,
where Request object is not available.
when I call
string webAppRootDir = Server.MapPath("/");
I get c:\intepub\wwwroot (one level too "high")
when calling:
string webAppRootDir = Server.MapPath("./");
I get c:\intepub\wwwroot\appname\[somedirectory] (one [or more] level too
"deep")
Actually this only works if at application startup somebody typed in browser:
http://machinename/appName
(specifically application name has not been suffixed with nested dir name)
Is there any universal [working also without Request object]
way to get web application physical root path?
Note: I do not know virtual directory name, and must get it
dynamically via code (but do not know how). If I know this,
I might call the code:
string webAppRootDir = Server.MapPath("/"+virtDirName);
Thanks for help
Michal Januszczyk
(Actually I need physical root directory of web application)
I want to open some files in web application root relative
directory.
Previously I used to open the files when client connected and
thus could use the following code to retreive physical file location:
string webAppRootDir = Server.MapPath(Request.ApplicationPath);
Now I would like to open the files in application startup routine,
where Request object is not available.
when I call
string webAppRootDir = Server.MapPath("/");
I get c:\intepub\wwwroot (one level too "high")
when calling:
string webAppRootDir = Server.MapPath("./");
I get c:\intepub\wwwroot\appname\[somedirectory] (one [or more] level too
"deep")
Actually this only works if at application startup somebody typed in browser:
http://machinename/appName
(specifically application name has not been suffixed with nested dir name)
Is there any universal [working also without Request object]
way to get web application physical root path?
Note: I do not know virtual directory name, and must get it
dynamically via code (but do not know how). If I know this,
I might call the code:
string webAppRootDir = Server.MapPath("/"+virtDirName);
Thanks for help
Michal Januszczyk