提交rbac
提交设置右键错位的bug
This commit is contained in:
70
DH.RBAC/Utility/Extension/MyEnvironment.cs
Normal file
70
DH.RBAC/Utility/Extension/MyEnvironment.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DH.RBAC.Utility.Extension
|
||||
{
|
||||
public class MyEnvironment
|
||||
{
|
||||
private static string _currentPath;
|
||||
public static void Init(string currentPath)
|
||||
{
|
||||
_currentPath = currentPath;
|
||||
}
|
||||
|
||||
public static string WebRootPath(string path)
|
||||
{
|
||||
return RootPath("/wwwroot" + path);
|
||||
}
|
||||
|
||||
public static string RootPath(string path)
|
||||
{
|
||||
string basePath = "";
|
||||
#if NETFRAMEWORK
|
||||
basePath = AppDomain.CurrentDomain.BaseDirectory.Replace("/", "\\");
|
||||
if (!basePath.EndsWith("\\"))
|
||||
{
|
||||
basePath += "\\";
|
||||
}
|
||||
path = path.Replace("/", "\\");
|
||||
if (path.StartsWith("\\"))
|
||||
{
|
||||
path = path.Substring(1, path.Length - 1);
|
||||
}
|
||||
return basePath + path;
|
||||
#else
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
basePath = AppDomain.CurrentDomain.BaseDirectory.Replace("/", "\\");
|
||||
if (!basePath.EndsWith("\\"))
|
||||
{
|
||||
basePath += "\\";
|
||||
}
|
||||
path = path.Replace("/", "\\");
|
||||
if (path.StartsWith("\\"))
|
||||
{
|
||||
path = path.Substring(1, path.Length - 1);
|
||||
}
|
||||
return basePath + path;
|
||||
}
|
||||
else
|
||||
{
|
||||
basePath = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/");
|
||||
if (!basePath.EndsWith("/"))
|
||||
{
|
||||
basePath += "/";
|
||||
}
|
||||
path = path.Replace("\\", "/");
|
||||
if (path.StartsWith("/"))
|
||||
{
|
||||
path = path.Substring(1, path.Length - 1);
|
||||
}
|
||||
return basePath + path;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user