場景 - 我需要訪問HTML模板以從我的業務邏輯層生成電子郵件。它是一個包含文件的子文件夾的類庫。當我試圖在單元測試以下代碼:在C#中實現文件訪問的最佳方式
string FilePath = string.Format(@"{0}\templates\MyFile.htm", Environment.CurrentDirectory);
string FilePath1 = string.Format(@"{0}\templates\MyFile.htm", System.AppDomain.CurrentDomain.BaseDirectory);
它用的是C:\ WINNT \ SYSTEM32 \或ASP.NET臨時文件夾的目錄。
什麼是最好的訪問此文件,而無需使用app.config或web.config文件?
[這是使用WCF服務]
我最終將文件路徑存儲在web.config文件中。 – 2008-11-05 22:44:45
[相關問題(控制檯應用程序而不是類庫)](http://stackoverflow.com/questions/97312/how-do-i-find-out-what-directory-my-console-app-is-running- in-with-c) – 2008-10-24 20:23:55