本文介绍了在哪里存储简单 .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、Media Player Classic - 我可以在没有任何安装的情况下使用它们),但它们将配置存储在其他地方.如何实现这一目标?

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 应用程序,包括低权限的 Click Once 版本.它的工作是在磁盘上找到适合存储数据的位置,并将其完全隐藏起来.它还具有与 Visual Studio 的良好 GUI 集成.

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 应用程序的配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 21:57