![](/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.