[英]C# Visual Studio 2010 ultimate include html files in ClickOnce Deployment
I have a C# program created in VS 2010 ultimate. 我有一个在VS 2010 Ultimate中创建的C#程序。 I have added .html files to be used as help files. 我添加了.html文件用作帮助文件。 The help files are in a directory in the same directory as the project file. 帮助文件与项目文件位于同一目录中。 Does anyone know what the path would be from current directory after deployment with ClickOnce? 有谁知道使用ClickOnce部署后当前目录的路径是什么? Nothing I have tried has worked. 我尝试过的一切都没有奏效。 I have also put the .html files in the same directory as project file but that doesn't work either. 我也将.html文件与项目文件放在同一目录中,但这也不起作用。 (I have added the .html files in project properties) (我已经在项目属性中添加了.html文件)
In the Solution Explorer, right click on your x.html
file and select Properties
. 在解决方案资源管理器中,右键单击x.html
文件,然后选择Properties
。 In the properties set Copy to Output Directory
setting to Copy always
. 在属性中,将“ Copy to Output Directory
设置为Copy always
。
In your code reference your x.html file using this code: 在您的代码中,使用以下代码引用您的x.html文件:
var directoryPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var filePath = Path.Combine(directoryPath, "x.html");
Have you tried adding the .HTML files to your project itself? 您是否尝试过将.HTML文件添加到项目本身? Then, inside the project set 'Copy To Output Directory' to True
? 然后,在项目内部将“复制到输出目录”设置为True
?
Go to the properties of the files and make sure Copy to Output
is true
. 转到文件的属性,并确保“ Copy to Output
为true
。 And then, you should be able to access them like this: 然后,您应该能够像这样访问它们:
string path = string.Format(@"{0}\{1}", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Path\To\The\File.txt");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.