I want to save a file when my application ends.
For that, I need to get the root folder of the application.
The only way I know to do that is using Server.MapPath("~")
, but this does not work, even through HttpContext.Current.Server
because there is not current context, as far as I understand.
Is there a smart & simple way to get that folder path? Will I have permission problems, trying to create a file in the root folder?
Any alternative ideas how to accomplish this?
You should use HttpRuntime.AppDomainAppPath
, which will always work.