您可以将设置的默认值设置为程序的当前工作目录吗?

发布于 2024-10-09 02:18:56 字数 293 浏览 0 评论 0原文

我正在使用 VS 2010 并尝试创建、加载和保存设置的功能。我从 http://www.codeproject.com/KB/cs/UserSettings.aspx< /a> 必须给出默认值字段。是否可以将字符串类型设置的默认值设置为应用程序运行目录?

如果不可能,我的做法是给出默认值“。”并在运行时检查它,如果需要,将其更改为程序的当前目录,但我愿意接受一些不那么棘手的建议。

I'm using VS 2010 and playing around with the ability to create, load, and save settings. I read from http://www.codeproject.com/KB/cs/UserSettings.aspx that the default value field must be given. Is it possible to set the default value of a string-type setting to the applications running directory?

If its not possible, my hack at it would be to give a default value of "." and check it at run-time, changing it to the program's current directory if needed, but I'm open to suggestions for something less hacky.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

剧终人散尽 2024-10-16 02:19:13

您可以将应用程序设置字符串变量设置为您想要的任何内容。只是您是否知道将默认值设置为某个值,检查该值并修改它,然后检查某个不能是目录的值要容易得多。

当然,您也可以在应用程序首次启动时添加设置变量,只需很少的代码。

You can set the an application setting string variable to anything you want. Just do you know its far easier to set the default value to something, check for that value and modify it, then check for some value that cannot be a directory.

Of course you could also add the setting variable when the application starts for the first-time with very little code.

混浊又暗下来 2024-10-16 02:19:08

使用“hack”并检测何时需要使用分配的值或其他值。

设置本质上是愚蠢的容器,对应用程序本身一无所知。

Go with the "hack" and detect when you need to use the assigned value or something else.

Settings are essentially dumb containers and know nothing about the app itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文