怪奇物语

怪奇物语

首页 新随笔 联系 管理

PathHelper,获取当前执行程序的叔叔文件夹

System.Console.WriteLine(PathHelper.GetExeCurDir());
System.Console.WriteLine(PathHelper.GetExeGrandFatherDir());
System.Console.WriteLine(PathHelper.GetExeUncleDir("Files"));
System.Console.WriteLine(PathHelper.GetExeUncleDir("Files\\TouchDownTestResultFolder"));

using System.Reflection;

public static class PathHelper
{
    public static string GetExeCurDir()
    {
        string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
        return exeDir;
    }

    public static string GetExeGrandFatherDir()
    {
        return Path.GetDirectoryName(PathHelper.GetExeCurDir())!;
    }

    public static string GetExeUncleDir(string uncleFolerName)
    {
        return Path.Combine(PathHelper.GetExeGrandFatherDir(), uncleFolerName);
    }
}

posted on 2025-06-19 08:00  超级无敌美少男战士  阅读(6)  评论(0)    收藏  举报