我正在尝试使用Windows服务读取文件但是找不到。正如通过我的服务读取文件一样吗?
string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Email\Template.html");
string test = File.ReadAllText(filePath)
答案 0 :(得分:1)
然后获取如下文件路径:
var path = AppDomain.CurrentDomain.BaseDirectory +“email \ Template.html”;
答案 1 :(得分:0)
确保" Copy To Output Directory"属性已启用此文件。