A tiny c# utility for Translate a web-relative path to a filesystem path (useful in scope where there is not a web server, for example inside services). The code is written in .NET C#.
The package is available on nuget
-
Translate a Web-Relative path to FileSystem-Path:
string ToFileSystemPath(string webrelativePath);
-
Translate a FileInfo full path to web-relative:
string ToWebRelativePath(FileInfo file);
-
Translate a DirectoryInfo full path to web-relative
string ToWebRelativePath(DirectoryInfo directory);
-
Return a FileInfo from its web-relative position:
FileInfo GetFile(string webrelativePath);
-
Return a DirectoryInfo from its web-relative position:
DirectoryInfo GetDirectory(string webrelativePath);
Translate web-path to filesystem path
IWebPathTranslator svc = new WebPathTranslator(@"c:\temp");
var result = svc.ToFileSystemPath("~/Folder1/Folder2");
//result is 'c:\temp\Folder1\Folder2'