markus / MarkusAutoUpdate / src / MarkusUpdateExtract / Program.cs @ 3276cb1c
이력 | 보기 | 이력해설 | 다운로드 (3.17 KB)
1 | d8f5045e | taeseongkim | using System; |
---|---|---|---|
2 | using System.IO; |
||
3 | using System.IO.Compression; |
||
4 | using System.Diagnostics; |
||
5 | using System.Linq; |
||
6 | using System.Security.AccessControl; |
||
7 | using System.ServiceModel; |
||
8 | using System.IO.MemoryMappedFiles; |
||
9 | using System.Text; |
||
10 | |||
11 | namespace MarkusUpdateExtract |
||
12 | { |
||
13 | class Program |
||
14 | { |
||
15 | [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] |
||
16 | static void Main(string[] args) |
||
17 | { |
||
18 | try |
||
19 | { |
||
20 | |||
21 | //args = new string[] |
||
22 | //{ |
||
23 | //@"C:\Program Files\Doftech\MARKUS", |
||
24 | //@"C:\Users\kts\AppData\Local\Temp\MARKUS\fwcp21al.rqk\", |
||
25 | //@"C:\Users\kts\AppData\Local\Temp\MARKUS\fwcp21al.rqk\Markus_3.0.0.zip", |
||
26 | //@"C:\Program Files\Doftech\MARKUS\KCOM.exe", |
||
27 | //"eyJEb2N1bWVudEl0ZW1JRCI6IjMwMDAwMTY1IiwiYlBhcnRuZXIiOmZhbHNlLCJDcmVhdGVGaW5hbFBERlBlcm1pc3Npb24iOnRydWUsIk5ld0NvbW1lbnRQZXJtaXNzaW9uIjp0cnVlLCJQcm9qZWN0Tk8iOiIwMDAwMDAiLCJVc2VySUQiOiJkb2Z0ZWNoIn0=" |
||
28 | //}; |
||
29 | |||
30 | Console.ReadKey(); |
||
31 | |||
32 | using (MemoryMappedFile mmf = MemoryMappedFile.OpenExisting("MarkusUpdateExtract",MemoryMappedFileRights.Read)) |
||
33 | { |
||
34 | using (Stream view = mmf.CreateViewStream()) |
||
35 | { |
||
36 | view.Position = 0; |
||
37 | |||
38 | using (StreamReader reader = new StreamReader(view, Encoding.UTF8)) |
||
39 | { |
||
40 | args = reader.ReadToEnd().Split(" "); |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 | |||
45 | var InstallPath = args[0]; |
||
46 | var tempStoragePath = args[1]; |
||
47 | var downloadfile = args[2]; |
||
48 | var kcomPath = args[3]; |
||
49 | var markusPram = args[4]; |
||
50 | |||
51 | //DirectoryInfo dInfo = new DirectoryInfo(InstallPath); |
||
52 | //DirectorySecurity dSecurity = dInfo.GetAccessControl(); |
||
53 | //dSecurity.AddAccessRule(new FileSystemAccessRule(System.Security.Principal.WindowsIdentity.GetCurrent().Name, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow)); |
||
54 | //dInfo.SetAccessControl(dSecurity); |
||
55 | |||
56 | var extractFolder = Path.Combine(tempStoragePath, "Extract"); |
||
57 | |||
58 | ZipFile.ExtractToDirectory(downloadfile, extractFolder, true); |
||
59 | |||
60 | foreach (var file in Directory.EnumerateFiles(extractFolder, "*.*", SearchOption.AllDirectories)) |
||
61 | { |
||
62 | var target = System.IO.Path.Combine(InstallPath, file.Replace(extractFolder, "").Substring(1)); |
||
63 | |||
64 | File.Copy(file, target, File.Exists(target)); |
||
65 | } |
||
66 | |||
67 | Process.Start(kcomPath, markusPram); |
||
68 | Console.ReadKey(); |
||
69 | Environment.Exit(1); |
||
70 | } |
||
71 | catch (Exception ex) |
||
72 | { |
||
73 | Console.WriteLine(ex.ToString()); |
||
74 | |||
75 | if(ex.InnerException != null) |
||
76 | Console.WriteLine(ex.InnerException.ToString()); |
||
77 | |||
78 | Console.ReadKey(); |
||
79 | Environment.Exit(1); |
||
80 | } |
||
81 | } |
||
82 | } |
||
83 | } |