@@ -44,9 +44,9 @@ private enum CurrentAction
4444 private CurrentAction _currentAction ;
4545 private Settings _settings ;
4646
47- private const int ResultsColumnCharset = 0 ;
48- private const int ResultsColumnFileName = 1 ;
49- private const int ResultsColumnDirectory = 2 ;
47+ private const int RESULTS_COLUMN_CHARSET = 0 ;
48+ private const int RESULTS_COLUMN_FILE_NAME = 1 ;
49+ private const int RESULTS_COLUMN_DIRECTORY = 2 ;
5050
5151 public MainForm ( )
5252 {
@@ -183,13 +183,15 @@ private void OnExport(object sender, EventArgs e)
183183 }
184184
185185 string filename1 = "" ;
186- SaveFileDialog saveFileDialog1 = new SaveFileDialog ( ) ;
187- saveFileDialog1 . Title = "Export to a Text File" ;
188- saveFileDialog1 . Filter = "txt files (*.txt)|*.txt" ;
189- saveFileDialog1 . RestoreDirectory = true ;
186+ SaveFileDialog saveFileDialog1 = new SaveFileDialog
187+ {
188+ Title = "Export to a Text File" ,
189+ Filter = "txt files (*.txt)|*.txt" ,
190+ RestoreDirectory = true
191+ } ;
190192 if ( saveFileDialog1 . ShowDialog ( ) == DialogResult . OK )
191193 {
192- filename1 = saveFileDialog1 . FileName . ToString ( ) ;
194+ filename1 = saveFileDialog1 . FileName ;
193195 }
194196
195197 if ( filename1 != "" )
@@ -200,15 +202,16 @@ private void OnExport(object sender, EventArgs e)
200202 {
201203 foreach ( ListViewItem item in lstResults . CheckedItems )
202204 {
203- string charset = item . SubItems [ ResultsColumnCharset ] . Text ;
204- string fileName = item . SubItems [ ResultsColumnFileName ] . Text ;
205- string directory = item . SubItems [ ResultsColumnDirectory ] . Text ;
205+ string charset = item . SubItems [ RESULTS_COLUMN_CHARSET ] . Text ;
206+ string fileName = item . SubItems [ RESULTS_COLUMN_FILE_NAME ] . Text ;
207+ string directory = item . SubItems [ RESULTS_COLUMN_DIRECTORY ] . Text ;
206208 sw . WriteLine ( "{0}\t {1}\\ {2}" , charset , directory , fileName ) ;
207209 }
208210 }
209211 }
210212 catch
211213 {
214+ // do nothing
212215 }
213216 }
214217 }
@@ -277,11 +280,11 @@ private void OnConvert(object sender, EventArgs e)
277280
278281 foreach ( ListViewItem item in lstResults . CheckedItems )
279282 {
280- string charset = item . SubItems [ ResultsColumnCharset ] . Text ;
283+ string charset = item . SubItems [ RESULTS_COLUMN_CHARSET ] . Text ;
281284 if ( charset == "(Unknown)" )
282285 continue ;
283- string fileName = item . SubItems [ ResultsColumnFileName ] . Text ;
284- string directory = item . SubItems [ ResultsColumnDirectory ] . Text ;
286+ string fileName = item . SubItems [ RESULTS_COLUMN_FILE_NAME ] . Text ;
287+ string directory = item . SubItems [ RESULTS_COLUMN_DIRECTORY ] . Text ;
285288 string filePath = Path . Combine ( directory , fileName ) ;
286289
287290 FileAttributes attributes = File . GetAttributes ( filePath ) ;
@@ -325,7 +328,7 @@ private void OnConvert(object sender, EventArgs e)
325328
326329 item . Checked = false ;
327330 item . ImageIndex = 0 ;
328- item . SubItems [ ResultsColumnCharset ] . Text = targetCharset ;
331+ item . SubItems [ RESULTS_COLUMN_CHARSET ] . Text = targetCharset ;
329332 }
330333
331334 // resume drawing of the results list view control
@@ -407,7 +410,7 @@ private static void ActionWorkerDoWork(object sender, DoWorkEventArgs e)
407410 if ( reportBufferCounter > 1 )
408411 {
409412 reportBufferCounter -- ;
410- int percentageCompleted = 100 ;
413+ const int percentageCompleted = 100 ;
411414 WorkerProgress [ ] reportProgress = new WorkerProgress [ reportBufferCounter ] ;
412415 Array . Copy ( progressBuffer , reportProgress , reportBufferCounter ) ;
413416 worker . ReportProgress ( percentageCompleted , reportProgress ) ;
@@ -486,7 +489,7 @@ private void LoadSettings()
486489 _settings = ( Settings ) settingsInstance ;
487490 }
488491
489- if ( _settings . RecentDirectories != null && _settings . RecentDirectories . Count > 0 )
492+ if ( _settings . RecentDirectories ? . Count > 0 )
490493 {
491494 foreach ( string recentDirectory in _settings . RecentDirectories )
492495 lstBaseDirectory . Items . Add ( recentDirectory ) ;
@@ -496,7 +499,7 @@ private void LoadSettings()
496499 lstBaseDirectory . Text = Environment . CurrentDirectory ;
497500 chkIncludeSubdirectories . Checked = _settings . IncludeSubdirectories ;
498501 txtFileMasks . Text = _settings . FileMasks ;
499- if ( _settings . ValidCharsets != null && _settings . ValidCharsets . Length > 0 )
502+ if ( _settings . ValidCharsets ? . Length > 0 )
500503 {
501504 for ( int i = 0 ; i < lstValidCharsets . Items . Count ; i ++ )
502505 if ( Array . Exists ( _settings . ValidCharsets ,
0 commit comments