在哪里存储一个简单的.NET应用程序的配置? [英] Where to store configuration for a simple .NET application?

查看:116
本文介绍了在哪里存储一个简单的.NET应用程序的配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程一个相当简单的应用程序,我想剪切到一个简单的EXE文件和一些数据存储(例如XML)。

I'm programming a fairly simple application which I want to cut to just one simple EXE file + some data storage (XML for example).

我的问题是关于配置文件。在哪里放这些文件?我看到一些只有一个EXE文件的应用程序(uTorrent,媒体播放器经典 - 我可以使用它们没有任何安装),但他们将其配置存储在其他地方。如何实现这一点?

My question is regarding configuration files. Where to put those files? I saw a few applications that have just an EXE file (uTorrent, Media Player Classic - I can use them without any installation), but they store their config somewhere else. How to achieve this?

你会如何处理这种情况?最好是尝试实现我上面描述的东西,或者只是使用一个配置文件和数据存储在同一目录下的EXE文件?

How would you approach such situation? Is it better to try to achieve the thing I described above, or simply use a configuration file and data storage in the same directory as the EXE file?

推荐答案

我想您想了解一下应用程序设置。这是一个API,它允许您使用强类型API保存用户或应用程序设置。在引擎盖下,设置通过XML序列化存储。

I think you want to take a look at Application Settings. This is an API which allows you to save user or application settings using a strongly typed API. Under the hood the settings are stored via XML serialization.

此API适用于几乎每种类型的.Net应用程序,包括低权限点击一次版本。它做的工作是找到适合存储数据的磁盘上的位置,并完全隐藏它。它还有一个很好的GUI集成到Visual Studio。

This API works with virtually every type of .Net application including low permission Click Once versions. It does the work of finding the place on disk appropriate for storing the data and completely hides it from you. It also has a nice GUI integration into Visual Studio.

这篇关于在哪里存储一个简单的.NET应用程序的配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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