@@ -61,42 +61,50 @@ private void loadprofiles()
6161 // load user profiles from the My Documents\.edseditor\profiles\ folder
6262 // Personal is my documents in windows and ~ in mono
6363
64- List < string > profilelist = Directory . GetFiles ( System . IO . Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . Location ) + Path . DirectorySeparatorChar + "Profiles" ) . ToList ( ) ;
65- string homepath = Path . Combine ( System . Environment . GetFolderPath ( Environment . SpecialFolder . Personal ) , ".edseditor" ) ;
66- homepath = Path . Combine ( homepath , "profiles" ) ;
67-
68- if ( Directory . Exists ( homepath ) )
64+ try
6965 {
70- profilelist . AddRange ( Directory . GetFiles ( homepath ) . ToList ( ) ) ;
71- }
7266
73- int count = 0 ;
74- //some attempt to validate files
67+ List < string > profilelist = Directory . GetFiles ( System . IO . Path . GetDirectoryName ( System . Reflection . Assembly . GetExecutingAssembly ( ) . Location ) + Path . DirectorySeparatorChar + "Profiles" ) . ToList ( ) ;
68+ string homepath = Path . Combine ( System . Environment . GetFolderPath ( Environment . SpecialFolder . Personal ) , ".edseditor" ) ;
69+ homepath = Path . Combine ( homepath , "profiles" ) ;
7570
76- foreach ( string file in profilelist )
77- {
78- if ( Path . GetExtension ( file ) == ".xml" )
79- count ++ ;
80- }
71+ if ( Directory . Exists ( homepath ) )
72+ {
73+ profilelist . AddRange ( Directory . GetFiles ( homepath ) . ToList ( ) ) ;
74+ }
75+
76+ int count = 0 ;
77+ //some attempt to validate files
78+
79+ foreach ( string file in profilelist )
80+ {
81+ if ( Path . GetExtension ( file ) == ".xml" )
82+ count ++ ;
83+ }
8184
8285
83- ToolStripMenuItem [ ] items = new ToolStripMenuItem [ count ] ;
86+ ToolStripMenuItem [ ] items = new ToolStripMenuItem [ count ] ;
8487
85- int x = 0 ;
86- foreach ( string file in profilelist )
87- {
88- if ( Path . GetExtension ( file ) == ".xml" )
88+ int x = 0 ;
89+ foreach ( string file in profilelist )
8990 {
90- ToolStripMenuItem i = new ToolStripMenuItem ( ) ;
91- i . Name = Path . GetFileName ( file ) ;
92- i . Text = Path . GetFileName ( file ) ;
93- i . Click += ProfileAddClick ;
94- i . Image = Properties . Resources . InsertColumn_5626 ;
95- items [ x ++ ] = i ;
91+ if ( Path . GetExtension ( file ) == ".xml" )
92+ {
93+ ToolStripMenuItem i = new ToolStripMenuItem ( ) ;
94+ i . Name = Path . GetFileName ( file ) ;
95+ i . Text = Path . GetFileName ( file ) ;
96+ i . Click += ProfileAddClick ;
97+ i . Image = Properties . Resources . InsertColumn_5626 ;
98+ items [ x ++ ] = i ;
99+ }
96100 }
97- }
98101
99- insertToolStripMenuItem . DropDownItems . AddRange ( items ) ;
102+ insertToolStripMenuItem . DropDownItems . AddRange ( items ) ;
103+ }
104+ catch ( Exception e )
105+ {
106+ MessageBox . Show ( "Loading profiles has failed for the following reason :\n " + e . ToString ( ) ) ;
107+ }
100108
101109 }
102110
0 commit comments