Get relative file path in a class library project that is being referenced by a web project

前端 未结 5 623
南方客
南方客 2020-12-08 16:48

I have an ASP.Net website that references a class library. In the class library I need to read a file into memory.

At the top level of my class library there is a fo

5条回答
  •  生来不讨喜
    2020-12-08 17:22

    using System.IO;    
    using System.Reflection;
    
    public static string ExecutionDirectoryPathName()
        {
             var dirPath = Assembly.GetExecutingAssembly().Location;
             dirPath = Path.GetDirectoryName(dirPath);
             return Path.GetFullPath(Path.Combine(dirPath, "\EmailTemplateHtml\MailTemplate.html"));
        }
    

提交回复
热议问题