开发者

Path.GetFullPath doesn't return correct path

开发者 https://www.devze.com 2023-01-31 08:13 出处:网络
I was trying to use System.IO.Path.GetFullPath(\"Database.mdf\") in the class DAL in a website im creating but instead of returning :

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

精彩评论

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