[英]How to read a html file from a Windows Service?
I'm trying to read a file using windows service but is giving as not found. 我正在尝试使用Windows服务读取文件,但没有找到。 As it does to read a file through my service?
可以通过我的服务读取文件吗?
string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Email\Template.html");
string test = File.ReadAllText(filePath)
and then get file path like this: 然后获取如下文件路径:
var path = AppDomain.CurrentDomain.BaseDirectory + "email\\Template.html"; var path = AppDomain.CurrentDomain.BaseDirectory +“ email \\ Template.html”;
Make sure that " Copy To Output Directory " property is Enabled for this file. 确保为此文件启用“ 复制到输出目录 ”属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.