Path.GetFullPath doesn't return correct path
I was trying to use System.IO.Path.GetFullPath("Database.mdf")
in the class DAL
in a website im creating but instead of returning :
F:\MyProject\App_Data\Database.mdf
I开发者_高级运维t Returns C:\\\\Program Files (x86)\\\Common Files\\\microsoftshared\\\DevServer\\\10.0\\\Database.mdf
Anyone has any idea on how to solve this?
Path.GetFullPath
return the full path of a file relative to the Environment.CurrentDirectory
. In a web environment, consider using HttpRequest.MapPath
.
Try this:
System.Web.HttpContext.Current.Request.MapPath("~/App_Data/Database.mdf")
精彩评论