How to get the absolute root folder path of a ASP .NET website / MVC website.

 

The following code result in my case to rootFolderPath = "C:\inetpub\wwwroot\MvcApplication1".

Uri uri = new System.Uri(Assembly.GetAssembly(typeof(MvcApplication)).CodeBase);
string binFolderPath = Path.GetDirectoryName(uri.LocalPath);
string rootFolderPath = new DirectoryInfo(binFolderPath).Parent.FullName;

Leave a Reply

Your email address will not be published. Required fields are marked *