11using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Text ;
5- using System . Threading . Tasks ;
62using System . Threading ;
73using System . Diagnostics ;
8- using System . Windows ;
94using System . Windows . Forms ;
105using System . IO ;
116using System . IO . Compression ;
@@ -17,61 +12,66 @@ public static class Program
1712 [ STAThread ]
1813 public static void Main ( )
1914 {
20- Process [ ] p = Process . GetProcessesByName ( "Spedit.exe" ) ;
21- if ( p . Length > 0 )
15+ var process = Process . GetProcessesByName ( "Spedit.exe" ) ;
16+
17+ if ( process . Length > 0 )
2218 {
23- for ( int i = 0 ; i < p . Length ; ++ i )
24- {
19+ foreach ( var p in process )
2520 try
2621 {
27- p [ i ] . WaitForExit ( ) ;
22+ p . WaitForExit ( ) ;
23+ }
24+ catch ( Exception )
25+ {
26+ // ignored
2827 }
29- catch ( Exception ) { }
30- }
3128 }
29+
3230 Application . EnableVisualStyles ( ) ;
3331 Application . SetCompatibleTextRenderingDefault ( true ) ;
34- UpdateMarquee um = new UpdateMarquee ( ) ;
32+
33+ var um = new UpdateMarquee ( ) ;
3534 um . Show ( ) ;
36- Application . DoEvents ( ) ; //execute Visual
37- Thread t = new Thread ( new ParameterizedThreadStart ( Worker ) ) ;
35+
36+ Application . DoEvents ( ) ;
37+
38+ var t = new Thread ( Worker ) ;
3839 t . Start ( um ) ;
40+
3941 Application . Run ( um ) ;
4042 }
4143
4244 private static void Worker ( object arg )
4345 {
44- UpdateMarquee um = ( UpdateMarquee ) arg ;
45- string zipFile = Path . Combine ( Environment . CurrentDirectory , "updateZipFile.zip" ) ;
46-
47- byte [ ] zipFileContent = SpeditUpdater . Properties . Resources . spedit1_2_0_1Update ;
46+ var um = ( UpdateMarquee ) arg ;
47+ var zipFile = Path . Combine ( Environment . CurrentDirectory , "updateZipFile.zip" ) ;
48+ var zipFileContent = Properties . Resources . spedit1_2_0_1Update ;
4849
4950 File . WriteAllBytes ( zipFile , zipFileContent ) ;
5051
51- FileInfo zipInfo = new FileInfo ( zipFile ) ;
52+ var zipInfo = new FileInfo ( zipFile ) ;
53+ var extractPath = Environment . CurrentDirectory ;
5254
53- string extractPath = Environment . CurrentDirectory ;
54- using ( ZipArchive archieve = ZipFile . OpenRead ( zipInfo . FullName ) )
55+ using ( var archieve = ZipFile . OpenRead ( zipInfo . FullName ) )
5556 {
5657 var entries = archieve . Entries ;
58+
5759 foreach ( var entry in entries )
5860 {
59- string full = Path . Combine ( extractPath , entry . FullName ) ;
60- FileInfo fInfo = new FileInfo ( full ) ;
61+ var full = Path . Combine ( extractPath , entry . FullName ) ;
62+ var fInfo = new FileInfo ( full ) ;
63+
6164 if ( ! Directory . Exists ( fInfo . DirectoryName ) )
62- {
63- Directory . CreateDirectory ( fInfo . DirectoryName ) ;
64- }
65+ if ( fInfo . DirectoryName != null )
66+ Directory . CreateDirectory ( fInfo . DirectoryName ) ;
67+
6568 entry . ExtractToFile ( fInfo . FullName , true ) ;
6669 }
6770 }
6871
6972 zipInfo . Delete ( ) ;
7073
71- um . Invoke ( ( InvokeDel ) ( ( ) =>
72- {
73- um . SetToReadyState ( ) ;
74- } ) ) ;
74+ um . Invoke ( ( InvokeDel ) ( ( ) => { um . SetToReadyState ( ) ; } ) ) ;
7575 }
7676
7777 public delegate void InvokeDel ( ) ;
0 commit comments