Files
EBoard/电子展板/Utility/Extension/MyEnvironment.cs
2025-09-22 14:30:54 +08:00

53 lines
1.5 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)
{
if (vPath == null)
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;
}
}
}