我正在研究Windows服務的c#程序。如何映射Windows服務程序的文件
我需要使用一個文件。這裏是我的代碼
const string mail_file_path = @"template\mailbody.html";
但根據我的日誌,有這樣的錯誤:
Error: Could not find a part of the path 'C:\Windows\system32\template\mailbody.html'.
我用app.configuration使用另一個文件
<add key="TimeStampFilePath" value="timestamp.ini" />
StreamReader sr = new StreamReader(ConfigurationManager.AppSettings["TimeStampFilePath"]);
但我無法讀取文件。
當我作爲一個簡單的Windows控制檯項目運行這個項目,它的工作原理。但是在我使用Windows服務模式運行它之後,出現了兩個問題。
該文件在哪裏?請提供完整的路徑。 – Oded
VS2010 \ Projects \ ProjectName \ bin \ Debug \ template \ mailbody.html VS2010 \ Projects \ ProjectName \ bin \ Debug \ timestamp.init – QianLi
@QuianLi:如果您複製服務器exe文件所在的模板文件夾,我的答案應該可行。 – CharithJ