How do I get the root directory of my ASP.NET server application?

Server.MapPath("~"); 

Will get you the root directory of the current application, as a path on the disk. E.g., C:\inetpub\...

Note that the ~ character can be used as part of web paths in ASP.NET controls as well, it’ll fill in the URL to your application.

If your class doesn’t have Server property, you can use static

HttpContext.Current.Server.MapPath("~")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)