Reputation: 59
I have stored Database in the main folder of my project, I am using Relative Path while i use that database. Now i need to convert this realtive path into absolute path at runtime I used tha following code but it doesnt work
string Path1 = @"Data Source=|DataDirectory|\MakeMyBill.sdf";
string fullpath=Path.GetFullPath(Path1);
Upvotes: 0
Views: 2216
Reputation: 457
try like HostingEnvironment
string logDirectory = HostingEnvironment.MapPath("~") + "\\" + "App_Data\\MakeMyBill.sdf";
or
string logDirectory =Server.MapPath("~/App_Data/MakeMyBill.sdf")
or on any folder
string filePath = @"D:\file\";
string directoryName = Path.GetDirectoryName(filePath);
filePath = directoryName + @"\file.xml";
Upvotes: 0