In ASP.Net there is the app_data folder which is not accessible to users via the web. I would like to store a file in this folder, and read from this file by using a class that I have in the App_Code folder.
Keep in mind that the current working directory here is going to be a directory such as "c:\","c:\windows\system32\", etc. and not the application directory. So something like "../App_Data/somefile" does not work.
There has to be something simple that I overlooked on how to access files in the App_Data folder programatically
How can I do this?
You say you don't have access to context object but it's unclear why that would be.
If your code runs in response to a request then you can access the context as :-
HttpContext.Current
Failing that you can get to the root physical path for the application using:-
HttpRuntime.AppDomainAppPath
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With