Storing default value in Application settings (C#)

与世无争的帅哥 提交于 2020-01-06 16:38:11

问题


I am using Application settings to store and retrieve my GUI settings. For one of the setting

Name - FileDirectory

Type - String

Scope - User

Value - Problem?? i need to store Desktop folder path i.e Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

I can't set this in Settings Page. How can i set this default value?

P.S I am using C# (.Net 2.0)


回答1:


may be a check at startup :

if(string.IsnullOrEmpty(Settings.Default.FileDirectory))
{
Settings.Default.FileDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
Settings.Default.Save();
}

Hope this help.



来源:https://stackoverflow.com/questions/1341821/storing-default-value-in-application-settings-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!