开发者

Can you set a setting's default value to the program's current working directory?

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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜