string basepath = @"C:\somefolder\subfolder\bin"; // is defined in runtime
string relative = @"..\..\templates";
string absolute = Magic(basepath, relative); // should be "C:\somefolder\templates"
Can you help me with Magic
method? Hopefully not too complicated code.
Is there the "Magic
" method in .NET Framework?
If you look at the Path
class there are a couple of methods which should help:
Path.Combine
and
Path.GetFullPath
So:
string newPath = Path.Combine(basepath, relative);
string absolute = Path.GetFullPath(newPath);
Although the second step isn't strictly needed - it would give you a "cleaner" path if you were printing out say.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With