Dont do this in the Properties itself ! Do this where your code wants to read the UserPathCode:namespace Red_Lining_Application.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); public static Settings Default { get { return defaultInstance; } } string path = string.Format(@"C:\Documents and Settings\{0}\My Documents\My Pictures", Environment.UserName); // I get an error trying to use Environment.Username. [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute(path)] public string UserPath { get { return ((string)(this["UserPath"])); } set { this["UserPath"] = value; } } } }
Simple instead of accessing the Properties
No need to have that code in the Properties. !!Code:string userpath = Properties.Settings.Default.UserPath; // do string userpath = string.Format(@"C:\Documents and Settings\{0}\My Documents\My Pictures", Environment.UserName);




Jonny Poet
Reply With Quote