如何从Windows服务中读取html文件?

时间:2016-08-04 17:12:38

标签: c# windows-services readfile

我正在尝试使用Windows服务读取文件但是找不到。正如通过我的服务读取文件一样吗?

string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Email\Template.html");

string test = File.ReadAllText(filePath)

Below where the file you want to read

2 个答案:

答案 0 :(得分:1)

  1. 右键单击Template.html - >特性
  2. 复制到输出目录 - >永远复制
  3. 然后获取如下文件路径:

    var path = AppDomain.CurrentDomain.BaseDirectory +“email \ Template.html”;

答案 1 :(得分:0)

确保" Copy To Output Directory"属性已启用此文件。

enter image description here