简体   繁体   中英

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.

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);

I have tried adding these as resources, but these files need to be editable, hence cannot be in exe.( Reference is this question )

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.

You create installers in Visual Studio by adding a Setup Project to the solution.

Link to tutorial on 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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