Reputation:
I have a path stored in a variable say
string partialPath = '\editors\tinymce'
I want to get the entire path of the above fie. The actual path of the above file is 'D:\Back up\editors\tinymce'. How can I do this in C#. Thanks
Upvotes: 0
Views: 448
Reputation: 61
please try with below code:
code:
string partialPath = "\editors\tinymce";
var output = Server.MapPath(partialPath);
string str = HttpContext.Current.Server.MapPath(partialPath);
you can get path on output var and str string.
let us know.
Upvotes: 0
Reputation: 14024
This might do the trick for you
string partialPath = "\editors\tinymce";
string fullPath = Path.GetFullPath(partialPath);
output:
D:\editors\tinymce
Whereas
This might do the trick for you
string partialPath = "editors\tinymce";
fullPath = Path.GetFullPath(partialPath);
output:
D:\Back up\editors\tinymce
Upvotes: 3
Reputation: 16277
var dir = Directory.GetCurrentDirectory();
var output = Path.Combine(dir, partialPath);
Upvotes: 3