forked from gordon-matt/elFinder.NetCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathHelper.cs
More file actions
24 lines (19 loc) · 739 Bytes
/
PathHelper.cs
File metadata and controls
24 lines (19 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
namespace elFinder.NetCore.Web;
public static class PathHelper
{
public static string WebRootPath { get; set; }
public static string GetFullPathNormalized(string path)
{
return Path.TrimEndingDirectorySeparator(Path.GetFullPath(path));
}
public static string MapPath(string path, string basePath = null)
{
basePath = string.IsNullOrEmpty(basePath) ? WebRootPath : basePath;
if (string.IsNullOrEmpty(basePath))
{
throw new ArgumentException("PathHelper does not have WebRootPath or basePath configured.");
}
path = path.Replace("~/", "").TrimStart('/').Replace('/', '\\');
return GetFullPathNormalized(Path.Combine(basePath, path));
}
}