![](/img/trans.png)
[英]How to include files and folders in the deployment of a visual studio, C# project?
[英]C# Visual Studio 2010 ultimate include html files in ClickOnce Deployment
我有一個在VS 2010 Ultimate中創建的C#程序。 我添加了.html文件用作幫助文件。 幫助文件與項目文件位於同一目錄中。 有誰知道使用ClickOnce部署后當前目錄的路徑是什么? 我嘗試過的一切都沒有奏效。 我也將.html文件與項目文件放在同一目錄中,但這也不起作用。 (我已經在項目屬性中添加了.html文件)
在解決方案資源管理器中,右鍵單擊x.html
文件,然后選擇Properties
。 在屬性中,將“ Copy to Output Directory
設置為Copy always
。
在您的代碼中,使用以下代碼引用您的x.html文件:
var directoryPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var filePath = Path.Combine(directoryPath, "x.html");
您是否嘗試過將.HTML文件添加到項目本身? 然后,在項目內部將“復制到輸出目錄”設置為True
?
轉到文件的屬性,並確保“ Copy to Output
為true
。 然后,您應該能夠像這樣訪問它們:
string path = string.Format(@"{0}\{1}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Path\To\The\File.txt");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.