51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|