存储项目文件夹,而不是应用程序数据的应用程序设置 [英] Storing Application Settings in Project Folder rather than AppData

查看:186
本文介绍了存储项目文件夹,而不是应用程序数据的应用程序设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目Settings.cs文件,并通过我

I have a Settings.cs file in my project, and I access the data in it from my program via

Properties.Settings.Default.MyProperty

生成的设置文件存储在以下位置

The generated settings file is stored in the following location

C:\Users\Foo\AppData\Local\MyApp\MyApp.exe_Url_jknwq2raeohczydfp1loj02nf05zldfk\1.0.0.0\user.config

的问题是,这不仅是特定的用户,但它也导致具有许多节目user.config文件每签名(调试/释放等),这迫使开发商,用户每次他启动一个不具有特定user.config然而程序的版本一次又一次填充整个设置。 (如果我不是很清楚,我会很高兴提供更多的细节)

The problem is that this is not only user specific, but it also results in the program having many user.config files for every signature (debug/release, etc.), which forces the developer-user to populate the whole settings again each time he launches a "version" of the program that does not have a specific user.config yet. (If I am not being clear enough, I'll be glad to give more details)

我想我的应用程序对所有用户和一个设置文件没有事情的版本(调试/释放,否则)。通过这种方式,dev的用户将不得不设置的设置一个单一的时间和这些设置将是有效的每次启动应用程序时,不需要重新输入他们的其他签名/用户。

I would like my application to have a single settings files for all users and no matter the "version" (debug/release, or else). This way, the dev-user would have to set the settings one single time and these settings would be effective each time the application is launched, without the need to re-enter them for the other signatures/users.

推荐答案

我最后选择了一个更简单直接的替代方案,包括创建一个普通的设置类和序列化/反序列化它描述的here

I Finally opted for a simpler straightforward alternative, consisting in creating a plain Settings class and Serializing/Deserializing it as described here

这篇关于存储项目文件夹,而不是应用程序数据的应用程序设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆