简体   繁体   English

如何在Windows窗体应用程序中发布配置文件和应用程序

[英]How to publish config files along with application in windows forms application

I have a very simple use case. 我有一个非常简单的用例。

1) I have 4 config files which are needed for the application to start. 1)我有4个配置文件,是应用程序启动所需的。

When I publish my application these files should be exported by default along with it. 当我发布我的应用程序时,默认情况下应该导出这些文件。 How can I do this ? 我怎样才能做到这一点 ? Where should the files be stored so that they are available when the pplication is installed? 应该在哪里存储文件,以便在安装应用程序时它们可用? The users of this application should be able to edit and access these files. 此应用程序的用户应该能够编辑和访问这些文件。

I have seen the option of saving it using string source = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); 我已经看到了使用string source = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);保存它的选项string source = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

I have tried adding these as resources, but these files need to be editable, hence cannot be in exe.( Reference is this question ) 我试过添加这些作为资源,但这些文件需要是可编辑的,因此不能在exe中。( 参考是这个问题

Please comment if you need additional information. 如果您需要其他信息,请发表评论。

If you're building the installer in Visual Studio, you can add those files as Content and it should be automatically included in the installer when it's built. 如果您在Visual Studio中构建安装程序,则可以将这些文件添加为内容,并且在构建时它应自动包含在安装程序中。

You create installers in Visual Studio by adding a Setup Project to the solution. 您可以通过向解决方案添加安装项目来在Visual Studio中创建安装程序。

Link to tutorial on MSDN: http://msdn.microsoft.com/en-us/library/vstudio/19x10e5c(v=vs.100).aspx 链接到MSDN教程: http//msdn.microsoft.com/en-us/library/vstudio/19x10e5c( v= vs.100).aspx

I recall it should automatically add all Content items automatically, but I'm a bit rusty. 我记得它应该自动自动添加所有内容项,但我有点生疏。 Here's more detail on how to add items to your installer, including desktop shortcuts and such: 以下是有关如何向安装程序添加项目的更多详细信息,包括桌面快捷方式等:

http://msdn.microsoft.com/en-us/library/vstudio/z11b431t(v=vs.100).aspx http://msdn.microsoft.com/en-us/library/vstudio/z11b431t(v=vs.100).aspx

Good luck! 祝好运!

There are meny ways to do whay you want to do. 你有什么想法的方法可以做。 the main question is why do you want to do it? 主要问题是你为什么要这样做? if you have a normal program for personal use you can simply link it to the needed file, meaning using the file without actual knowledge that it's there. 如果你有一个正常的个人使用程序,你可以简单地将它链接到所需的文件,这意味着使用该文件而不知道它在那里。

if it's for a task then you can zip them together, that way you'll know they are together, without adding them as resource. 如果它是一个任务,那么你可以将它们压缩在一起,这样你就会知道它们在一起,而不是将它们作为资源添加。

for other kind of use, or if you have to add them as resources, just add them like shown here 对于其他类型的使用,或者如果你有将其添加为资源,只需添加他们像显示在这里

for more reading on what do you need and how to do it i have here linked vs. Embeded resources 有关您需要什么以及如何做的更多阅读我在这里链接与嵌入资源

good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM