File tree Expand file tree Collapse file tree 1 file changed +28
-10
lines changed
eFormAPI/Installation/AllowMultipleVersionsBundle Expand file tree Collapse file tree 1 file changed +28
-10
lines changed Original file line number Diff line number Diff line change 55using System . Security ;
66using Microsoft . Win32 ;
77using System . Reflection ;
8+ using System . Threading ;
89
910namespace AlowMultipleVersionsBundle
1011{
@@ -14,6 +15,11 @@ static void Main(string[] args)
1415 {
1516 try
1617 {
18+ string path = Path . Combine ( Path . GetTempPath ( ) , "Eform Angular Frontend.exe" ) ;
19+ if ( IsFileLocked ( path ) )
20+ // wait for previous installer finish
21+ Thread . Sleep ( 2000 ) ;
22+
1723 var unistall =
1824 Registry . LocalMachine . OpenSubKey ( @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" ,
1925 true ) ;
@@ -27,17 +33,9 @@ static void Main(string[] args)
2733
2834 SetupIIS ( ) ;
2935
30- string path = Path . Combine ( Path . GetTempPath ( ) , "Eform Angular Frontend.exe" ) ;
31-
32- try
33- {
36+ if ( ! IsFileLocked ( path ) )
3437 File . WriteAllBytes ( path , Resources . Eform_Angular_Frontend ) ;
35- }
36- catch
37- {
38- // in case if installer already running, there is no need to write its sources
39- }
40-
38+
4139 var drive = DriveInfo . GetDrives ( ) . First ( t => t . DriveType == DriveType . Fixed ) . Name ;
4240 var tmpDir = Path . Combine ( drive , "tmp" ) ;
4341 if ( Directory . Exists ( tmpDir ) )
@@ -56,6 +54,26 @@ static void Main(string[] args)
5654
5755 }
5856
57+ static bool IsFileLocked ( string path )
58+ {
59+ FileStream stream = null ;
60+
61+ try
62+ {
63+ stream = File . Open ( path , FileMode . Open , FileAccess . Read , FileShare . None ) ;
64+ }
65+ catch ( IOException )
66+ {
67+ return true ;
68+ }
69+ finally
70+ {
71+ if ( stream != null )
72+ stream . Close ( ) ;
73+ }
74+ return false ;
75+ }
76+
5977 static void SetupIIS ( )
6078 {
6179 var featureNames = new [ ]
You can’t perform that action at this time.
0 commit comments