简体   繁体   中英

Storing default value in Application settings (C#)

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 ie Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

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

PS I am using C# (.Net 2.0)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM