初始化提交
This commit is contained in:
50
电子展板/Utility/Extension/MyEnvironment.cs
Normal file
50
电子展板/Utility/Extension/MyEnvironment.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace 电子展板.Utility.Extension
|
||||
{
|
||||
public class MyEnvironment
|
||||
{
|
||||
public static string WebRootPath(string path)
|
||||
{
|
||||
if (!path.StartsWith("/"))
|
||||
{
|
||||
path += "/";
|
||||
}
|
||||
return Root("/wwwroot" + path);
|
||||
}
|
||||
public static string Root(string vPath)
|
||||
{
|
||||
string path = Environment.CurrentDirectory.Replace("/", "\\");
|
||||
if (!path.EndsWith("\\")) path += "\\";
|
||||
vPath = vPath.Replace("/", "\\");
|
||||
if (vPath.StartsWith("\\"))
|
||||
{
|
||||
vPath = vPath.Substring(1);
|
||||
}
|
||||
return path + vPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插件所在路径
|
||||
/// </summary>
|
||||
/// <param name="plugType"></param>
|
||||
/// <param name="vPath"></param>
|
||||
/// <returns></returns>
|
||||
public static string PlugRoot(Type plugType, string vPath)
|
||||
{
|
||||
string path = plugType.Assembly.Location;
|
||||
path = path.Substring(0, path.LastIndexOf("\\"));
|
||||
if (!path.EndsWith("\\")) path += "\\";
|
||||
vPath = vPath.Replace("/", "\\");
|
||||
if (vPath.StartsWith("\\"))
|
||||
{
|
||||
vPath = vPath.Substring(1);
|
||||
}
|
||||
return path + vPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user