Or Betzalel
Or Betzalel

Reputation: 2597

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

It Returns C:\\\\Program Files (x86)\\\Common Files\\\microsoftshared\\\DevServer\\\10.0\\\Database.mdf

Anyone has any idea on how to solve this?

Upvotes: 1

Views: 6352

Answers (2)

grenade
grenade

Reputation: 32179

Try this:

System.Web.HttpContext.Current.Request.MapPath("~/App_Data/Database.mdf")

Upvotes: 4

Sam B
Sam B

Reputation: 2481

Path.GetFullPath return the full path of a file relative to the Environment.CurrentDirectory . In a web environment, consider using HttpRequest.MapPath .

Upvotes: 6

Related Questions