Get current directory in asp.net mvc

前端 未结 3 1761
别跟我提以往
别跟我提以往 2021-01-01 12:35

I am trying to construct a file path in order to read an XSLT file, like so:

string path = \"../_xslt/example.xslt\";
StreamReader reader = new StreamReader(         


        
3条回答
  •  被撕碎了的回忆
    2021-01-01 13:18

    string TestX()
    {
        string path = AppDomain.CurrentDomain.BaseDirectory; // You get main rott
        string dirc = ""; // just var for use
        string[] pathes = Directory.GetDirectories(path); // get collection
    
        foreach (string str in pathes)
        {
            if (str.Contains("NameYRDirectory")) // paste yr directory
            {
                dirc = str;
            }
        }
    
        return dirc; // after use Method and modify as you like
    }
    

提交回复
热议问题