开发者

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")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜