Accessing App_Data from App_Code

S

Sushi

Hi
I am developing an application using ASP.Net 2.0. In my code under
App_Code I would like to access the files in App_Data. Any ideas if
there is a way to get the path of this folder ?

Thanks
 
S

Sushi

No, that doesnt work. In my case the current directory when loading a
file seems to be the Visual Studio install directory.
 
J

Juan T. Llibre

That can't be.

"~" refers to an ASP.NET application's *virtual* directory
root and cannot possibly refer to VS's physical installation directory.
 
Joined
Jun 9, 2008
Messages
1
Reaction score
0
I know this is an old thread, just thought I'd update it for the googlers.

"~/App_Data" does indeed not work. Even if the resident 'MVP' thinks so..:flute:

you have to use Server.MapPath to get the "~" to work in something other than markup in asp.net. Only in the app_code folder, you don't have direct access to Server.MapPath, so you get something like:

HttpContext.Current.Server.MapPath("~/App_Data");

Hope this helps someone
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top