├── MAutoUpdate
├── Zip DLL
│ ├── ZipFile.cs
│ ├── ZipFile.SaveSelfExtractor.cs
│ ├── Migrated rules for Zip DLL.ruleset
│ ├── ZipConstants.cs
│ ├── ZipFile.Static.cs
│ ├── ZipEntrySource.cs
│ ├── msbuild.flymake.xml
│ ├── OffsetStream.cs
│ ├── ExtractExistingFileAction.cs
│ ├── ZipErrorAction.cs
│ ├── ComHelper.cs
│ ├── ZlibConstants.cs
│ ├── EncryptionAlgorithm.cs
│ ├── ZipFile.x-IEnumerable.cs
│ ├── Exceptions.cs
│ ├── ZipFile.Extract.cs
│ ├── ZipFile.Check.cs
│ └── ZipDirEntry.cs
├── app.config
├── config.update
├── Local.xml
├── Properties
│ ├── Settings.settings
│ ├── AssemblyInfo.cs
│ ├── Settings.Designer.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Server.xml
├── RemoteInfo.cs
├── LogTool.cs
├── UpdateForm.cs
├── app.manifest
├── YButton.cs
├── LocalInfo.cs
├── MainForm.cs
├── UpdateForm.Designer.cs
├── Program.cs
├── UpdateForm.resx
├── MainForm.Designer.cs
├── MAutoUpdate.csproj
└── MainForm.resx
├── MAutoUpdate.Test
├── Properties
│ ├── Settings.settings
│ ├── AssemblyInfo.cs
│ ├── Settings.Designer.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── Form1.cs
├── Program.cs
├── Form1.Designer.cs
├── MAutoUpdate.Test.csproj
└── Form1.resx
├── .gitattributes
├── AutoUpdate.sln
├── README.md
└── .gitignore
/MAutoUpdate/Zip DLL/ZipFile.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hello-Mango/MAutoUpdate/HEAD/MAutoUpdate/Zip DLL/ZipFile.cs
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipFile.SaveSelfExtractor.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Hello-Mango/MAutoUpdate/HEAD/MAutoUpdate/Zip DLL/ZipFile.SaveSelfExtractor.cs
--------------------------------------------------------------------------------
/MAutoUpdate/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MAutoUpdate/config.update:
--------------------------------------------------------------------------------
1 | [regedit_del]
2 | SOFTWARE\\Hello\\Printer,name
3 | [regedit_add]
4 | SOFTWARE\\Hello\\Printer,name=John Doe
5 | [file_del]
6 | hello.dll
7 |
--------------------------------------------------------------------------------
/MAutoUpdate/Local.xml:
--------------------------------------------------------------------------------
1 |
2 | 1.0.0.0
3 | 1.1.0.0
4 | 2016/9/28 9:25:24
5 | http://localhost/huidu/server.xml
6 |
--------------------------------------------------------------------------------
/MAutoUpdate/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace MAutoUpdate.Test
10 | {
11 | public partial class Form1 : Form
12 | {
13 | public Form1()
14 | {
15 | InitializeComponent();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/MAutoUpdate/Server.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 | demo.exe
5 | Print
6 | 1.0.0.0
7 | 2017/9/28 9:25:24
8 | http://localhost/WebApp/update/1.1.0.0.zip
9 | 1.1.0.0
10 | 1、Increment$2、hello$3、123456
11 | Increment
12 |
13 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | # Custom for Visual Studio
3 | *.cs diff=csharp
4 | *.sln merge=union
5 | *.csproj merge=union
6 | *.vbproj merge=union
7 | *.fsproj merge=union
8 | *.dbproj merge=union
9 |
10 | # Standard to msysgit
11 | *.doc diff=astextplain
12 | *.DOC diff=astextplain
13 | *.docx diff=astextplain
14 | *.DOCX diff=astextplain
15 | *.dot diff=astextplain
16 | *.DOT diff=astextplain
17 | *.pdf diff=astextplain
18 | *.PDF diff=astextplain
19 | *.rtf diff=astextplain
20 | *.RTF diff=astextplain
21 |
--------------------------------------------------------------------------------
/MAutoUpdate/RemoteInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MAutoUpdate
6 | {
7 | public class RemoteInfo
8 | {
9 | public String ApplicationStart { get; set; }
10 | public String AppName { get; set; }
11 | public String MinVersion { get; set; }
12 | public String ReleaseDate { get; set; }
13 | public String ReleaseUrl { get; set; }
14 | public String ReleaseVersion { get; set; }
15 | public String UpdateMode { get; set; }
16 | public String VersionDesc { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/Migrated rules for Zip DLL.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MAutoUpdate/LogTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Text;
6 |
7 | namespace MAutoUpdate
8 | {
9 | public static class LogTool
10 | {
11 | static string temp = AppDomain.CurrentDomain.BaseDirectory;
12 | public static void AddLog(String value)
13 | {
14 | Debug.WriteLine(value);
15 | if (Directory.Exists(Path.Combine(temp, @"log\")) == false)
16 | {
17 | DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(temp, @"log\"));
18 | directoryInfo.Create();
19 | }
20 | using (StreamWriter sw = File.AppendText(Path.Combine(temp, @"log\update.log")))
21 | {
22 | sw.WriteLine(value);
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MAutoUpdate/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过下列属性集
6 | // 控制。更改这些属性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("AutoUpdate")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AutoUpdate")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 属性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("276417b2-b45c-4c7d-902e-82730c1c3399")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.1.1.1")]
37 |
--------------------------------------------------------------------------------
/MAutoUpdate/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MAutoUpdate.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.8.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("MAutoUpdate.Test")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MAutoUpdate.Test")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("ae611095-8ef9-419c-9d2c-a17373aa6396")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Windows.Forms;
6 |
7 | namespace MAutoUpdate.Test
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | string path = AppDomain.CurrentDomain.BaseDirectory + "MAutoUpdate.exe";
18 | //同时启动自动更新程序
19 | if (File.Exists(path))
20 | {
21 | ProcessStartInfo processStartInfo = new ProcessStartInfo()
22 | {
23 | FileName = "MAutoUpdate.exe",
24 | Arguments = " MAutoUpdate.Test 1"
25 | };
26 | Process proc = Process.Start(processStartInfo);
27 | if (proc != null)
28 | {
29 | proc.WaitForExit();
30 | }
31 | }
32 | Application.EnableVisualStyles();
33 | Application.SetCompatibleTextRenderingDefault(false);
34 | Application.Run(new Form1());
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MAutoUpdate.Test.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace MAutoUpdate.Test
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.SuspendLayout();
32 | //
33 | // Form1
34 | //
35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37 | this.ClientSize = new System.Drawing.Size(566, 321);
38 | this.Name = "Form1";
39 | this.Text = "Form1";
40 | this.ResumeLayout(false);
41 |
42 | }
43 |
44 | #endregion
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/MAutoUpdate/UpdateForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Diagnostics;
6 | using System.Drawing;
7 | using System.Text;
8 | using System.Threading;
9 | using System.Windows.Forms;
10 |
11 | namespace MAutoUpdate
12 | {
13 | public partial class UpdateForm : Form
14 | {
15 | public delegate void UpdateUI(int step);//声明一个更新主线程的委托
16 | public UpdateUI UpdateUIDelegate;
17 | private UpdateWork work;
18 | public UpdateForm(UpdateWork _work)
19 | {
20 | work = _work;
21 | InitializeComponent();
22 | UpdateUIDelegate = new UpdateUI((obj) =>
23 | {
24 | this.updateBar.Value = obj;
25 | });
26 | work.OnUpdateProgess += new UpdateWork.UpdateProgess((obj) =>
27 | {
28 | this.Invoke(UpdateUIDelegate, (int)obj);
29 | });
30 | }
31 |
32 | private void UpdateForm_Load(object sender, EventArgs e)
33 | {
34 | ThreadPool.QueueUserWorkItem((obj) =>
35 | {
36 | try
37 | {
38 | work.Do();
39 | this.DialogResult = DialogResult.OK;
40 | }
41 | catch (Exception EX)
42 | {
43 | MessageBox.Show(EX.Message);
44 | }
45 | });
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/AutoUpdate.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27130.2036
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MAutoUpdate", "MAutoUpdate\MAutoUpdate.csproj", "{A41F9740-A368-4F0C-91CE-ACF24D0DCA60}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MAutoUpdate.Test", "MAutoUpdate.Test\MAutoUpdate.Test.csproj", "{AE611095-8EF9-419C-9D2C-A17373AA6396}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {A41F9740-A368-4F0C-91CE-ACF24D0DCA60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {A41F9740-A368-4F0C-91CE-ACF24D0DCA60}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {A41F9740-A368-4F0C-91CE-ACF24D0DCA60}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {A41F9740-A368-4F0C-91CE-ACF24D0DCA60}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {AE611095-8EF9-419C-9D2C-A17373AA6396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {AE611095-8EF9-419C-9D2C-A17373AA6396}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {AE611095-8EF9-419C-9D2C-A17373AA6396}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {AE611095-8EF9-419C-9D2C-A17373AA6396}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {559C136B-D826-44B3-8A7D-7A265066C27A}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # MAutoUpdate
4 | ## 配置说明
5 | Server.xml
6 | ```xml
7 |
8 |
9 | -
10 | demo.exe//更新后启动的程序
11 | Print//程序名称(暂时没用)
12 | 1.0.0.0//最小版本号(暂时没用)
13 | 2017/9/28 9:25:24//发布时间
14 | http://localhost/WebApp/update/1.1.0.0.zip//下载地址
15 | 1.1.0.0//发布版本号
16 | 更新说明文件的链接地址信息,rtf的格式//更新界面提示信息
17 | Increment//Cover表示覆盖更新,Increment表示增量更新
18 |
19 |
20 | ```
21 | Local.xml
22 | ```xml
23 |
24 | 1.0.0.0//本地版本号
25 | 2016/9/28 9:25:24//最后更新时间
26 | http://localhost/TestWeb/Server.xml//server.xml文件地址
27 |
28 | ```
29 | ## 使用方法
30 | 启动更新程序方法
31 | ```C#
32 | [STAThread]
33 | static void Main()
34 | {
35 | String path = AppDomain.CurrentDomain.BaseDirectory + "MAutoUpdate.exe";//程序路径
36 | //同时启动自动更新程序
37 | if (File.Exists(path))//判断是否存在更新程序
38 | {
39 | ProcessStartInfo processStartInfo = new ProcessStartInfo()
40 | {
41 | FileName = "MAutoUpdate.exe",
42 | Arguments = " MAutoUpdate.Test 1"//参数信息,程序名称 0:弹窗更新 1:静默更新
43 | };
44 | Process proc = Process.Start(processStartInfo);
45 | if (proc != null)
46 | {
47 | proc.WaitForExit();
48 | }
49 | }
50 | Application.EnableVisualStyles();
51 | Application.SetCompatibleTextRenderingDefault(false);
52 | Application.Run(new Form1());
53 | }
54 | ```
55 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipConstants.cs:
--------------------------------------------------------------------------------
1 | // ZipConstants.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2006, 2007, 2008, 2009 Dino Chiesa and Microsoft Corporation.
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-August-27 23:22:32>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines a few constants that are used in the project.
23 | //
24 | // ------------------------------------------------------------------
25 |
26 | using System;
27 |
28 | namespace Ionic.Zip
29 | {
30 | static class ZipConstants
31 | {
32 | public const UInt32 PackedToRemovableMedia = 0x30304b50;
33 | public const UInt32 Zip64EndOfCentralDirectoryRecordSignature = 0x06064b50;
34 | public const UInt32 Zip64EndOfCentralDirectoryLocatorSignature = 0x07064b50;
35 | public const UInt32 EndOfCentralDirectorySignature = 0x06054b50;
36 | public const int ZipEntrySignature = 0x04034b50;
37 | public const int ZipEntryDataDescriptorSignature = 0x08074b50;
38 | public const int SplitArchiveSignature = 0x08074b50;
39 | public const int ZipDirEntrySignature = 0x02014b50;
40 |
41 |
42 | // These are dictated by the Zip Spec.See APPNOTE.txt
43 | public const int AesKeySize = 192; // 128, 192, 256
44 | public const int AesBlockSize = 128; // ???
45 |
46 | public const UInt16 AesAlgId128 = 0x660E;
47 | public const UInt16 AesAlgId192 = 0x660F;
48 | public const UInt16 AesAlgId256 = 0x6610;
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipFile.Static.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Ionic.Zip
6 | {
7 | partial class ZipFile
8 | {
9 | private static System.Text.Encoding _defaultEncoding = null;
10 | private static bool _defaultEncodingInitialized = false;
11 |
12 | ///
13 | ///
14 | ///
15 | /// Static constructor for ZipFile
16 | ///
17 | ///
18 | /// Code Pages 437 and 1252 for English are same
19 | /// Code Page 1252 Windows Latin 1 (ANSI) -
20 | /// Code Page 437 MS-DOS Latin US -
21 | ///
22 | static ZipFile()
23 | {
24 | System.Text.Encoding ibm437 = null;
25 | try
26 | {
27 | ibm437 = System.Text.Encoding.GetEncoding("IBM437");
28 | }
29 | catch (Exception /*e*/)
30 | {
31 |
32 | }
33 | #if !WINDOWS_PHONE_APP
34 | if (ibm437 == null)
35 | {
36 | try
37 | {
38 | ibm437 = System.Text.Encoding.GetEncoding(1252);
39 | }
40 | catch (Exception /*e*/)
41 | {
42 |
43 | }
44 | }
45 | #endif
46 | _defaultEncoding = ibm437;
47 | }
48 |
49 | ///
50 | /// The default text encoding used in zip archives. It is numeric 437, also
51 | /// known as IBM437.
52 | ///
53 | ///
54 | public static System.Text.Encoding DefaultEncoding
55 | {
56 | get
57 | {
58 | return _defaultEncoding;
59 | }
60 | set
61 | {
62 | if (_defaultEncodingInitialized)
63 | {
64 | return;
65 | }
66 | _defaultEncoding = value;
67 | _defaultEncodingInitialized = true;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipEntrySource.cs:
--------------------------------------------------------------------------------
1 | // ZipEntrySource.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-November-19 11:18:42>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 |
23 | namespace Ionic.Zip
24 | {
25 | ///
26 | /// An enum that specifies the source of the ZipEntry.
27 | ///
28 | public enum ZipEntrySource
29 | {
30 | ///
31 | /// Default value. Invalid on a bonafide ZipEntry.
32 | ///
33 | None = 0,
34 |
35 | ///
36 | /// The entry was instantiated by calling AddFile() or another method that
37 | /// added an entry from the filesystem.
38 | ///
39 | FileSystem,
40 |
41 | ///
42 | /// The entry was instantiated via or
43 | /// .
44 | ///
45 | Stream,
46 |
47 | ///
48 | /// The ZipEntry was instantiated by reading a zipfile.
49 | ///
50 | ZipFile,
51 |
52 | ///
53 | /// The content for the ZipEntry will be or was provided by the WriteDelegate.
54 | ///
55 | WriteDelegate,
56 |
57 | ///
58 | /// The content for the ZipEntry will be obtained from the stream dispensed by the OpenDelegate.
59 | /// The entry was instantiated via .
60 | ///
61 | JitStream,
62 |
63 | ///
64 | /// The content for the ZipEntry will be or was obtained from a ZipOutputStream.
65 | ///
66 | ZipOutputStream,
67 | }
68 |
69 | }
--------------------------------------------------------------------------------
/MAutoUpdate/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/msbuild.flymake.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 | false
10 | true
11 |
12 | .\
13 | .\
14 | .\obj\
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
50 |
51 |
52 |
53 |
54 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/MAutoUpdate/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MAutoUpdate.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MAutoUpdate.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MAutoUpdate.Test.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 强类型资源类,用于查找本地化字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的缓存 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MAutoUpdate.Test.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 覆盖当前线程的 CurrentUICulture 属性
56 | /// 使用此强类型的资源类的资源查找。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/MAutoUpdate/YButton.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Drawing;
5 | using System.Data;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 | namespace MAutoUpdate.Control
10 | {
11 | public partial class YButton : Label
12 | {
13 | private Boolean isColorChange = true;
14 | private Boolean isFontChange = false;
15 |
16 | public Boolean IsFontChange
17 | {
18 | get { return isFontChange; }
19 | set { isFontChange = value; }
20 | }
21 |
22 | public Boolean IsColorChange
23 | {
24 | get { return isColorChange; }
25 | set { isColorChange = value; }
26 | }
27 | private Color normalColor = Color.FromArgb(56, 95, 170);
28 |
29 | public Color NormalColor
30 | {
31 | get { return normalColor; }
32 | set { normalColor = value; }
33 | }
34 | private Color moveColor = Color.FromArgb(128, 156, 211);
35 |
36 | public Color MoveColor
37 | {
38 | get { return moveColor; }
39 | set { moveColor = value; }
40 | }
41 | private Color moveFontColor = Color.FromArgb(128, 156, 211);
42 |
43 | public Color MoveFontColor
44 | {
45 | get { return moveFontColor; }
46 | set { moveFontColor = value; }
47 | }
48 | private Color normalFontColor = Color.FromArgb(128, 156, 211);
49 |
50 | public Color NormalFontColor
51 | {
52 | get { return normalFontColor; }
53 | set { normalFontColor = value; }
54 | }
55 | public Image EnterImage { get; set; }
56 |
57 | public YButton()
58 | : base()
59 | {
60 | this.Size = new Size(61, 23);
61 | this.ForeColor = Color.FromArgb(240, 240, 240);
62 | this.BackColor = normalColor;
63 | this.TextAlign = ContentAlignment.MiddleCenter;
64 | this.AutoSize = false;
65 | }
66 |
67 | protected override void OnMouseEnter(EventArgs e)
68 | {
69 | if (isColorChange)
70 | {
71 | this.BackColor = moveColor;
72 | }
73 | if (isFontChange)
74 | {
75 | this.ForeColor =this.moveFontColor;
76 | }
77 |
78 | base.OnMouseEnter(e);
79 | }
80 |
81 | protected override void OnMouseLeave(EventArgs e)
82 | {
83 | if (isColorChange)
84 | {
85 | this.BackColor = normalColor;
86 | }
87 | if (isFontChange)
88 | {
89 | this.ForeColor = this.normalFontColor;
90 | }
91 | base.OnMouseLeave(e);
92 | }
93 |
94 | protected override void OnPaint(PaintEventArgs e)
95 | {
96 | base.OnPaint(e);
97 |
98 | }
99 |
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/MAutoUpdate/LocalInfo.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Win32;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Text;
6 | using System.Xml;
7 |
8 | namespace MAutoUpdate
9 | {
10 | public class LocalInfo
11 | {
12 | public string LocalVersion { get; set; }
13 | public string LastUdpate { get; set; }
14 | public string ServerUpdateUrl { get; set; }
15 | public string LocalIgnoreVersion { get; set; }
16 |
17 | private string url = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Local.xml");
18 |
19 |
20 | public LocalInfo(string localAddress)
21 | {
22 | url = Path.Combine(localAddress, "Local.xml");
23 | }
24 |
25 | public void SaveReg(string subKey)
26 | {
27 | RegistryKey Key;
28 | Key = Registry.CurrentUser;
29 | //Key = Key.OpenSubKey("SOFTWARE\\GoodMES\\Update");
30 | Key = Key.OpenSubKey(subKey, true);
31 |
32 | foreach (var item in this.GetType().GetProperties())
33 | {
34 | Key.SetValue(item.Name.ToString(), this.GetType().GetProperty(item.Name.ToString()).GetValue(this, null).ToString());
35 | }
36 | }
37 | public void LoadReg(string subKey)
38 | {
39 | //获取本地配置文件
40 | RegistryKey Key;
41 | Key = Registry.CurrentUser;
42 | Key = Key.OpenSubKey(subKey);
43 |
44 | foreach (var item in this.GetType().GetProperties())
45 | {
46 | this.GetType().GetProperty(item.Name.ToString()).SetValue(this, Key.GetValue(item.Name.ToString()).ToString(), null);
47 | }
48 | Key.Close();
49 | }
50 | public void LoadXml()
51 | {
52 | XmlDocument xdoc = new XmlDocument();
53 | xdoc.Load(url);
54 | var root = xdoc.DocumentElement;
55 | var listNodes = root.SelectNodes("/LocalUpdate");
56 | foreach (XmlNode item in listNodes)
57 | {
58 | RemoteInfo remote = new RemoteInfo();
59 | foreach (XmlNode pItem in item.ChildNodes)
60 | {
61 | GetType().GetProperty(pItem.Name).SetValue(this, pItem.InnerText, null);
62 | }
63 | }
64 | }
65 | public void SaveXml()
66 | {
67 | XmlDocument xdoc = new XmlDocument();
68 | xdoc.Load(url);
69 | var root = xdoc.DocumentElement;
70 | var listNodes = root.SelectNodes("/LocalUpdate");
71 | foreach (XmlNode item in listNodes)
72 | {
73 | foreach (XmlNode pItem in item.ChildNodes)
74 | {
75 | // Key.SetValue(item.Name.ToString(), this.GetType().GetProperty(item.Name.ToString()).GetValue(this, null).ToString());
76 | pItem.InnerText = this.GetType().GetProperty(pItem.Name.ToString()).GetValue(this, null).ToString();
77 | }
78 | }
79 | xdoc.Save(url);
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/OffsetStream.cs:
--------------------------------------------------------------------------------
1 | // OffsetStream.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-August-27 12:50:35>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines logic for handling reading of zip archives embedded
23 | // into larger streams. The initial position of the stream serves as
24 | // the base offset for all future Seek() operations.
25 | //
26 | // ------------------------------------------------------------------
27 |
28 |
29 | using System;
30 | using System.IO;
31 |
32 | namespace Ionic.Zip
33 | {
34 | internal class OffsetStream : System.IO.Stream, System.IDisposable
35 | {
36 | private Int64 _originalPosition;
37 | private Stream _innerStream;
38 |
39 | public OffsetStream(Stream s)
40 | : base()
41 | {
42 | _originalPosition = s.Position;
43 | _innerStream = s;
44 | }
45 |
46 | public override int Read(byte[] buffer, int offset, int count)
47 | {
48 | return _innerStream.Read(buffer, offset, count);
49 | }
50 |
51 | public override void Write(byte[] buffer, int offset, int count)
52 | {
53 | throw new NotImplementedException();
54 | }
55 |
56 | public override bool CanRead
57 | {
58 | get { return _innerStream.CanRead; }
59 | }
60 |
61 | public override bool CanSeek
62 | {
63 | get { return _innerStream.CanSeek; }
64 | }
65 |
66 | public override bool CanWrite
67 | {
68 | get { return false; }
69 | }
70 |
71 | public override void Flush()
72 | {
73 | _innerStream.Flush();
74 | }
75 |
76 | public override long Length
77 | {
78 | get
79 | {
80 | return _innerStream.Length;
81 | }
82 | }
83 |
84 | public override long Position
85 | {
86 | get { return _innerStream.Position - _originalPosition; }
87 | set { _innerStream.Position = _originalPosition + value; }
88 | }
89 |
90 |
91 | public override long Seek(long offset, System.IO.SeekOrigin origin)
92 | {
93 | return _innerStream.Seek(_originalPosition + offset, origin) - _originalPosition;
94 | }
95 |
96 |
97 | public override void SetLength(long value)
98 | {
99 | throw new NotImplementedException();
100 | }
101 |
102 | void IDisposable.Dispose()
103 | {
104 | Close();
105 | }
106 |
107 | public override void Close()
108 | {
109 | base.Close();
110 | }
111 |
112 | }
113 |
114 | }
--------------------------------------------------------------------------------
/MAutoUpdate.Test/MAutoUpdate.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {AE611095-8EF9-419C-9D2C-A17373AA6396}
8 | WinExe
9 | MAutoUpdate.Test
10 | MAutoUpdate.Test
11 | v2.0
12 | 512
13 |
14 |
15 | AnyCPU
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | AnyCPU
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | Form
44 |
45 |
46 | Form1.cs
47 |
48 |
49 |
50 |
51 | Form1.cs
52 |
53 |
54 | ResXFileCodeGenerator
55 | Resources.Designer.cs
56 | Designer
57 |
58 |
59 | True
60 | Resources.resx
61 |
62 |
63 | SettingsSingleFileGenerator
64 | Settings.Designer.cs
65 |
66 |
67 | True
68 | Settings.settings
69 | True
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/MAutoUpdate/MainForm.cs:
--------------------------------------------------------------------------------
1 | using Ionic.Zip;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Diagnostics;
7 | using System.Drawing;
8 | using System.IO;
9 | using System.IO.Compression;
10 | using System.Net;
11 | using System.Runtime.InteropServices;
12 | using System.Text;
13 | using System.Threading;
14 | using System.Windows.Forms;
15 | using System.Xml;
16 |
17 | namespace MAutoUpdate
18 | {
19 | public partial class MainForm : Form
20 | {
21 | UpdateWork updateWork;
22 | public MainForm(UpdateWork _updateWork)
23 | {
24 | InitializeComponent();
25 | updateWork = _updateWork;
26 | var res = _updateWork.UpdateVerList[_updateWork.UpdateVerList.Count - 1].VersionDesc;
27 |
28 | var temp = WebRequest.Create(res);
29 | var stream = temp.GetResponse().GetResponseStream();
30 | using (StreamReader reader = new StreamReader(stream, System.Text.Encoding.Default))
31 | {
32 | string text = reader.ReadToEnd();
33 | this.lblContent.Text = text;
34 | }
35 | //foreach (var item in _updateWork.UpdateVerList[_updateWork.UpdateVerList.Count - 1].VersionDesc.Split('$'))
36 | //{
37 | // this.lblContent.Text = this.lblContent.Text + item + Environment.NewLine;
38 | //}
39 | }
40 | #region 让窗体变成可移动
41 | [DllImport("user32.dll")]
42 | public static extern bool ReleaseCapture();
43 | [DllImport("user32.dll")]
44 | public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
45 |
46 | [DllImport("User32.dll")]
47 | private static extern IntPtr WindowFromPoint(Point p);
48 |
49 | public const int WM_SYSCOMMAND = 0x0112;
50 | public const int SC_MOVE = 0xF010;
51 | public const int HTCAPTION = 0x0002;
52 | private IntPtr moveObject = IntPtr.Zero; //拖动窗体的句柄
53 |
54 | private void PNTop_MouseDown(object sender, MouseEventArgs e)
55 | {
56 | if (moveObject == IntPtr.Zero)
57 | {
58 | if (this.Parent != null)
59 | {
60 | moveObject = this.Parent.Handle;
61 | }
62 | else
63 | {
64 | moveObject = this.Handle;
65 | }
66 | }
67 | ReleaseCapture();
68 | SendMessage(moveObject, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
69 | }
70 |
71 | #endregion
72 |
73 |
74 | ///
75 | /// 如果以后更新,则将更新程序关闭
76 | ///
77 | ///
78 | ///
79 | private void btnUpdateLater_Click(object sender, EventArgs e)
80 | {
81 | Application.Exit();
82 | }
83 |
84 | private void btnUpdateNow_Click(object sender, EventArgs e)
85 | {
86 | this.Visible = false;//隐藏当前窗口
87 | UpdateForm updateForm = new UpdateForm(updateWork);
88 | if (updateForm.ShowDialog() == DialogResult.OK)
89 | {
90 | Application.Exit();
91 | }
92 | }
93 |
94 | private void btnIgnore_Click(object sender, EventArgs e)
95 | {
96 | updateWork.IgnoreThisVersion();
97 | Application.Exit();
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ExtractExistingFileAction.cs:
--------------------------------------------------------------------------------
1 | // ExtractExistingFileAction.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-August-25 08:44:37>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines the ExtractExistingFileAction enum
23 | //
24 | //
25 | // ------------------------------------------------------------------
26 |
27 |
28 | namespace Ionic.Zip
29 | {
30 |
31 | ///
32 | /// An enum for the options when extracting an entry would overwrite an existing file.
33 | ///
34 | ///
35 | ///
36 | ///
37 | /// This enum describes the actions that the library can take when an
38 | /// Extract() or ExtractWithPassword() method is called to extract an
39 | /// entry to a filesystem, and the extraction would overwrite an existing filesystem
40 | /// file.
41 | ///
42 | ///
43 | ///
44 | public enum ExtractExistingFileAction
45 | {
46 | ///
47 | /// Throw an exception when extraction would overwrite an existing file. (For
48 | /// COM clients, this is a 0 (zero).)
49 | ///
50 | Throw,
51 |
52 | ///
53 | /// When extraction would overwrite an existing file, overwrite the file silently.
54 | /// The overwrite will happen even if the target file is marked as read-only.
55 | /// (For COM clients, this is a 1.)
56 | ///
57 | OverwriteSilently,
58 |
59 | ///
60 | /// When extraction would overwrite an existing file, don't overwrite the file, silently.
61 | /// (For COM clients, this is a 2.)
62 | ///
63 | DoNotOverwrite,
64 |
65 | ///
66 | /// When extraction would overwrite an existing file, invoke the ExtractProgress
67 | /// event, using an event type of . In
69 | /// this way, the application can decide, just-in-time, whether to overwrite the
70 | /// file. For example, a GUI application may wish to pop up a dialog to allow
71 | /// the user to choose. You may want to examine the property before making
73 | /// the decision. If, after your processing in the Extract progress event, you
74 | /// want to NOT extract the file, set
75 | /// on the ZipProgressEventArgs.CurrentEntry to DoNotOverwrite.
76 | /// If you do want to extract the file, set ZipEntry.ExtractExistingFile
77 | /// to OverwriteSilently. If you want to cancel the Extraction, set
78 | /// ZipProgressEventArgs.Cancel to true. Cancelling differs from using
79 | /// DoNotOverwrite in that a cancel will not extract any further entries, if
80 | /// there are any. (For COM clients, the value of this enum is a 3.)
81 | ///
82 | InvokeExtractProgressEvent,
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/MAutoUpdate/UpdateForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace MAutoUpdate
2 | {
3 | partial class UpdateForm
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.updateBar = new System.Windows.Forms.ProgressBar();
32 | this.LBTitle = new System.Windows.Forms.Label();
33 | this.label1 = new System.Windows.Forms.Label();
34 | this.SuspendLayout();
35 | //
36 | // updateBar
37 | //
38 | this.updateBar.BackColor = System.Drawing.Color.Lime;
39 | this.updateBar.Location = new System.Drawing.Point(40, 299);
40 | this.updateBar.Name = "updateBar";
41 | this.updateBar.Size = new System.Drawing.Size(509, 28);
42 | this.updateBar.TabIndex = 24;
43 | //
44 | // LBTitle
45 | //
46 | this.LBTitle.AutoSize = true;
47 | this.LBTitle.BackColor = System.Drawing.Color.Transparent;
48 | this.LBTitle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold);
49 | this.LBTitle.ForeColor = System.Drawing.Color.DimGray;
50 | this.LBTitle.Location = new System.Drawing.Point(12, 9);
51 | this.LBTitle.Name = "LBTitle";
52 | this.LBTitle.Size = new System.Drawing.Size(54, 19);
53 | this.LBTitle.TabIndex = 25;
54 | this.LBTitle.Text = "新版本";
55 | //
56 | // label1
57 | //
58 | this.label1.BackColor = System.Drawing.Color.Transparent;
59 | this.label1.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold);
60 | this.label1.ForeColor = System.Drawing.Color.DimGray;
61 | this.label1.Location = new System.Drawing.Point(95, 243);
62 | this.label1.Name = "label1";
63 | this.label1.Size = new System.Drawing.Size(407, 19);
64 | this.label1.TabIndex = 26;
65 | this.label1.Text = "正在升级...";
66 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
67 | //
68 | // UpdateForm
69 | //
70 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
71 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
72 | this.ClientSize = new System.Drawing.Size(588, 428);
73 | this.Controls.Add(this.label1);
74 | this.Controls.Add(this.LBTitle);
75 | this.Controls.Add(this.updateBar);
76 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
77 | this.Name = "UpdateForm";
78 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
79 | this.Text = "UpdateForm";
80 | this.Load += new System.EventHandler(this.UpdateForm_Load);
81 | this.ResumeLayout(false);
82 | this.PerformLayout();
83 |
84 | }
85 |
86 | #endregion
87 |
88 | private System.Windows.Forms.ProgressBar updateBar;
89 | private System.Windows.Forms.Label LBTitle;
90 | private System.Windows.Forms.Label label1;
91 | }
92 | }
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipErrorAction.cs:
--------------------------------------------------------------------------------
1 | // ZipErrorAction.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-September-01 18:43:20>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines the ZipErrorAction enum, which provides
23 | // an action to take when errors occur when opening or reading
24 | // files to be added to a zip file.
25 | //
26 | // ------------------------------------------------------------------
27 |
28 |
29 | namespace Ionic.Zip
30 | {
31 | ///
32 | /// An enum providing the options when an error occurs during opening or reading
33 | /// of a file or directory that is being saved to a zip file.
34 | ///
35 | ///
36 | ///
37 | ///
38 | /// This enum describes the actions that the library can take when an error occurs
39 | /// opening or reading a file, as it is being saved into a Zip archive.
40 | ///
41 | ///
42 | ///
43 | /// In some cases an error will occur when DotNetZip tries to open a file to be
44 | /// added to the zip archive. In other cases, an error might occur after the
45 | /// file has been successfully opened, while DotNetZip is reading the file.
46 | ///
47 | ///
48 | ///
49 | /// The first problem might occur when calling AddDirectory() on a directory
50 | /// that contains a Clipper .dbf file; the file is locked by Clipper and
51 | /// cannot be opened by another process. An example of the second problem is
52 | /// the ERROR_LOCK_VIOLATION that results when a file is opened by another
53 | /// process, but not locked, and a range lock has been taken on the file.
54 | /// Microsoft Outlook takes range locks on .PST files.
55 | ///
56 | ///
57 | public enum ZipErrorAction
58 | {
59 | ///
60 | /// Throw an exception when an error occurs while zipping. This is the default
61 | /// behavior. (For COM clients, this is a 0 (zero).)
62 | ///
63 | Throw,
64 |
65 | ///
66 | /// When an error occurs during zipping, for example a file cannot be opened,
67 | /// skip the file causing the error, and continue zipping. (For COM clients,
68 | /// this is a 1.)
69 | ///
70 | Skip,
71 |
72 | ///
73 | /// When an error occurs during zipping, for example a file cannot be opened,
74 | /// retry the operation that caused the error. Be careful with this option. If
75 | /// the error is not temporary, the library will retry forever. (For COM
76 | /// clients, this is a 2.)
77 | ///
78 | Retry,
79 |
80 | ///
81 | /// When an error occurs, invoke the zipError event. The event type used is
82 | /// . A typical use of this option:
83 | /// a GUI application may wish to pop up a dialog to allow the user to view the
84 | /// error that occurred, and choose an appropriate action. After your
85 | /// processing in the error event, if you want to skip the file, set on the
87 | /// ZipProgressEventArgs.CurrentEntry to Skip. If you want the
88 | /// exception to be thrown, set ZipErrorAction on the CurrentEntry
89 | /// to Throw. If you want to cancel the zip, set
90 | /// ZipProgressEventArgs.Cancel to true. Cancelling differs from using
91 | /// Skip in that a cancel will not save any further entries, if there are any.
92 | /// (For COM clients, the value of this enum is a 3.)
93 | ///
94 | InvokeErrorEvent,
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ComHelper.cs:
--------------------------------------------------------------------------------
1 | // ComHelper.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa.
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2011-June-13 17:04:06>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines a COM Helper class.
23 | //
24 | // Created: Tue, 08 Sep 2009 22:03
25 | //
26 |
27 | using Interop=System.Runtime.InteropServices;
28 |
29 | namespace Ionic.Zip
30 | {
31 | ///
32 | /// This class exposes a set of COM-accessible wrappers for static
33 | /// methods available on the ZipFile class. You don't need this
34 | /// class unless you are using DotNetZip from a COM environment.
35 | ///
36 | [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000F")]
37 | [System.Runtime.InteropServices.ComVisible(true)]
38 | #if !NETCF
39 | [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
40 | #endif
41 |
42 | public class ComHelper
43 | {
44 | ///
45 | /// A wrapper for ZipFile.IsZipFile(string)
46 | ///
47 | /// The filename to of the zip file to check.
48 | /// true if the file contains a valid zip file.
49 | public bool IsZipFile(string filename)
50 | {
51 | return ZipFile.IsZipFile(filename);
52 | }
53 |
54 | ///
55 | /// A wrapper for ZipFile.IsZipFile(string, bool)
56 | ///
57 | ///
58 | /// We cannot use "overloaded" Method names in COM interop.
59 | /// So, here, we use a unique name.
60 | ///
61 | /// The filename to of the zip file to check.
62 | /// true if the file contains a valid zip file.
63 | public bool IsZipFileWithExtract(string filename)
64 | {
65 | return ZipFile.IsZipFile(filename, true);
66 | }
67 |
68 | #if !NETCF
69 | ///
70 | /// A wrapper for ZipFile.CheckZip(string)
71 | ///
72 | /// The filename to of the zip file to check.
73 | ///
74 | /// true if the named zip file checks OK. Otherwise, false.
75 | public bool CheckZip(string filename)
76 | {
77 | return ZipFile.CheckZip(filename);
78 | }
79 |
80 | ///
81 | /// A COM-friendly wrapper for the static method .
82 | ///
83 | ///
84 | /// The filename to of the zip file to check.
85 | ///
86 | /// The password to check.
87 | ///
88 | /// true if the named zip file checks OK. Otherwise, false.
89 | public bool CheckZipPassword(string filename, string password)
90 | {
91 | return ZipFile.CheckZipPassword(filename, password);
92 | }
93 |
94 | ///
95 | /// A wrapper for ZipFile.FixZipDirectory(string)
96 | ///
97 | /// The filename to of the zip file to fix.
98 | public void FixZipDirectory(string filename)
99 | {
100 | ZipFile.FixZipDirectory(filename);
101 | }
102 | #endif
103 |
104 | ///
105 | /// A wrapper for ZipFile.LibraryVersion
106 | ///
107 | ///
108 | /// the version number on the DotNetZip assembly, formatted as a string.
109 | ///
110 | public string GetZipLibraryVersion()
111 | {
112 | return ZipFile.LibraryVersion.ToString();
113 | }
114 |
115 | }
116 | }
--------------------------------------------------------------------------------
/MAutoUpdate/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Forms;
4 | using System.IO;
5 | using System.Net;
6 | using System.Diagnostics;
7 | using System.Threading;
8 | using System.Xml;
9 |
10 | namespace MAutoUpdate
11 | {
12 | static class Program
13 | {
14 | static bool f;
15 | static Process pCurrent = Process.GetCurrentProcess();
16 | static Mutex m = new Mutex(true, pCurrent.MainModule.FileName.Replace(":", "").Replace(@"\", "") + "MAutoUpdate", out f);//互斥,
17 |
18 | ///
19 | /// 程序主入口
20 | ///
21 | /// [0]程序名称,[1]静默更新 0:否 1:是 [3] 0:程序启动检测 1:手动点击检查更新按钮(在于忽略更新的情况下,手动检测时候还是要弹出来的)
22 | [STAThread]
23 | static void Main(string[] args)
24 | {
25 | if (f)
26 | {
27 | try
28 | {
29 | string programName = args[0];
30 | string silentUpdate = args[1];
31 | string isClickUpdate = "0";
32 | string localAddress = AppDomain.CurrentDomain.BaseDirectory;
33 | if (args.Length == 3)
34 | {
35 | isClickUpdate = args[2];
36 | }
37 | if (string.IsNullOrEmpty(programName) == false)
38 | {
39 | UpdateWork updateWork = new UpdateWork(programName, localAddress, isClickUpdate);
40 | if (updateWork.UpdateVerList.Count > 0)
41 | {
42 | /* 当前用户是管理员的时候,直接启动应用程序
43 | * 如果不是管理员,则使用启动对象启动程序,以确保使用管理员身份运行
44 | */
45 | //获得当前登录的Windows用户标示
46 | System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
47 | //创建Windows用户主题
48 | Application.EnableVisualStyles();
49 | System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);
50 | //判断当前登录用户是否为管理员
51 | if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
52 | {
53 | if (silentUpdate == "1")
54 | {
55 | updateWork.Do();
56 | }
57 | else
58 | {
59 | Application.EnableVisualStyles();
60 | Application.SetCompatibleTextRenderingDefault(false);
61 | Application.Run(new MainForm(updateWork));
62 | }
63 | }
64 | else
65 | {
66 | string result = Environment.GetEnvironmentVariable("systemdrive");
67 | if (AppDomain.CurrentDomain.BaseDirectory.Contains(result))
68 | {
69 | //创建启动对象
70 | ProcessStartInfo startInfo = new ProcessStartInfo
71 | {
72 | //设置运行文件
73 | FileName = System.Windows.Forms.Application.ExecutablePath,
74 | //设置启动动作,确保以管理员身份运行
75 | Verb = "runas",
76 |
77 | Arguments = " " + programName + " " + silentUpdate
78 | };
79 | //如果不是管理员,则启动UAC
80 | System.Diagnostics.Process.Start(startInfo);
81 | }
82 | else
83 | {
84 | if (silentUpdate == "1")
85 | {
86 | updateWork.Do();
87 | }
88 | else
89 | {
90 | Application.EnableVisualStyles();
91 | Application.SetCompatibleTextRenderingDefault(false);
92 | Application.Run(new MainForm(updateWork));
93 | }
94 | }
95 | }
96 | }
97 | }
98 | }
99 | catch (Exception ex)
100 | {
101 | MessageBox.Show(ex.Message);
102 | }
103 | }
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZlibConstants.cs:
--------------------------------------------------------------------------------
1 | // ZlibConstants.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-November-03 18:50:19>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines constants used by the zlib class library. This
23 | // code is derived from the jzlib implementation of zlib, but
24 | // significantly modified. In keeping with the license for jzlib, the
25 | // copyright to that code is included here.
26 | //
27 | // ------------------------------------------------------------------
28 | //
29 | // Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
30 | //
31 | // Redistribution and use in source and binary forms, with or without
32 | // modification, are permitted provided that the following conditions are met:
33 | //
34 | // 1. Redistributions of source code must retain the above copyright notice,
35 | // this list of conditions and the following disclaimer.
36 | //
37 | // 2. Redistributions in binary form must reproduce the above copyright
38 | // notice, this list of conditions and the following disclaimer in
39 | // the documentation and/or other materials provided with the distribution.
40 | //
41 | // 3. The names of the authors may not be used to endorse or promote products
42 | // derived from this software without specific prior written permission.
43 | //
44 | // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
45 | // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
46 | // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
47 | // INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
48 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
50 | // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
51 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
52 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 | //
55 | // -----------------------------------------------------------------------
56 | //
57 | // This program is based on zlib-1.1.3; credit to authors
58 | // Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
59 | // and contributors of zlib.
60 | //
61 | // -----------------------------------------------------------------------
62 |
63 |
64 | using System;
65 |
66 | namespace Ionic.Zlib
67 | {
68 | ///
69 | /// A bunch of constants used in the Zlib interface.
70 | ///
71 | public static class ZlibConstants
72 | {
73 | ///
74 | /// The maximum number of window bits for the Deflate algorithm.
75 | ///
76 | public const int WindowBitsMax = 15; // 32K LZ77 window
77 |
78 | ///
79 | /// The default number of window bits for the Deflate algorithm.
80 | ///
81 | public const int WindowBitsDefault = WindowBitsMax;
82 |
83 | ///
84 | /// indicates everything is A-OK
85 | ///
86 | public const int Z_OK = 0;
87 |
88 | ///
89 | /// Indicates that the last operation reached the end of the stream.
90 | ///
91 | public const int Z_STREAM_END = 1;
92 |
93 | ///
94 | /// The operation ended in need of a dictionary.
95 | ///
96 | public const int Z_NEED_DICT = 2;
97 |
98 | ///
99 | /// There was an error with the stream - not enough data, not open and readable, etc.
100 | ///
101 | public const int Z_STREAM_ERROR = -2;
102 |
103 | ///
104 | /// There was an error with the data - not enough data, bad data, etc.
105 | ///
106 | public const int Z_DATA_ERROR = -3;
107 |
108 | ///
109 | /// There was an error with the working buffer.
110 | ///
111 | public const int Z_BUF_ERROR = -5;
112 |
113 | ///
114 | /// The size of the working buffer used in the ZlibCodec class. Defaults to 8192 bytes.
115 | ///
116 | #if NETCF
117 | public const int WorkingBufferSizeDefault = 8192;
118 | #else
119 | public const int WorkingBufferSizeDefault = 16384;
120 | #endif
121 | ///
122 | /// The minimum size of the working buffer used in the ZlibCodec class. Currently it is 128 bytes.
123 | ///
124 | public const int WorkingBufferSizeMin = 1024;
125 | }
126 |
127 | }
128 |
129 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/EncryptionAlgorithm.cs:
--------------------------------------------------------------------------------
1 | // EncryptionAlgorithm.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-October-21 17:24:45>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines the EncryptionAgorithm enum
23 | //
24 | //
25 | // ------------------------------------------------------------------
26 |
27 |
28 | namespace Ionic.Zip
29 | {
30 | ///
31 | /// An enum that provides the various encryption algorithms supported by this
32 | /// library.
33 | ///
34 | ///
35 | ///
36 | ///
37 | ///
38 | /// PkzipWeak implies the use of Zip 2.0 encryption, which is known to be
39 | /// weak and subvertible.
40 | ///
41 | ///
42 | ///
43 | /// A note on interoperability: Values of PkzipWeak and None are
44 | /// specified in PKWARE's zip
46 | /// specification, and are considered to be "standard". Zip archives
47 | /// produced using these options will be interoperable with many other zip tools
48 | /// and libraries, including Windows Explorer.
49 | ///
50 | ///
51 | ///
52 | /// Values of WinZipAes128 and WinZipAes256 are not part of the Zip
53 | /// specification, but rather imply the use of a vendor-specific extension from
54 | /// WinZip. If you want to produce interoperable Zip archives, do not use these
55 | /// values. For example, if you produce a zip archive using WinZipAes256, you
56 | /// will be able to open it in Windows Explorer on Windows XP and Vista, but you
57 | /// will not be able to extract entries; trying this will lead to an "unspecified
58 | /// error". For this reason, some people have said that a zip archive that uses
59 | /// WinZip's AES encryption is not actually a zip archive at all. A zip archive
60 | /// produced this way will be readable with the WinZip tool (Version 11 and
61 | /// beyond).
62 | ///
63 | ///
64 | ///
65 | /// There are other third-party tools and libraries, both commercial and
66 | /// otherwise, that support WinZip's AES encryption. These will be able to read
67 | /// AES-encrypted zip archives produced by DotNetZip, and conversely applications
68 | /// that use DotNetZip to read zip archives will be able to read AES-encrypted
69 | /// archives produced by those tools or libraries. Consult the documentation for
70 | /// those other tools and libraries to find out if WinZip's AES encryption is
71 | /// supported.
72 | ///
73 | ///
74 | ///
75 | /// In case you care: According to the WinZip specification, the
77 | /// actual AES key used is derived from the via an
78 | /// algorithm that complies with RFC 2898, using an iteration
80 | /// count of 1000. The algorithm is sometimes referred to as PBKDF2, which stands
81 | /// for "Password Based Key Derivation Function #2".
82 | ///
83 | ///
84 | ///
85 | /// A word about password strength and length: The AES encryption technology is
86 | /// very good, but any system is only as secure as the weakest link. If you want
87 | /// to secure your data, be sure to use a password that is hard to guess. To make
88 | /// it harder to guess (increase its "entropy"), you should make it longer. If
89 | /// you use normal characters from an ASCII keyboard, a password of length 20 will
90 | /// be strong enough that it will be impossible to guess. For more information on
91 | /// that, I'd encourage you to read this
93 | /// article.
94 | ///
95 | ///
96 | ///
97 | /// The WinZip AES algorithms are not supported with the version of DotNetZip that
98 | /// runs on the .NET Compact Framework. This is because .NET CF lacks the
99 | /// HMACSHA1 class that is required for producing the archive.
100 | ///
101 | ///
102 | public enum EncryptionAlgorithm
103 | {
104 | ///
105 | /// No encryption at all.
106 | ///
107 | None = 0,
108 |
109 | ///
110 | /// Traditional or Classic pkzip encryption.
111 | ///
112 | PkzipWeak,
113 |
114 | #if AESCRYPTO
115 | ///
116 | /// WinZip AES encryption (128 key bits).
117 | ///
118 | WinZipAes128,
119 |
120 | ///
121 | /// WinZip AES encryption (256 key bits).
122 | ///
123 | WinZipAes256,
124 | #endif
125 |
126 | ///
127 | /// An encryption algorithm that is not supported by DotNetZip.
128 | ///
129 | Unsupported = 4,
130 |
131 |
132 | // others... not implemented (yet?)
133 | }
134 |
135 | }
136 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/MAutoUpdate.Test/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/MAutoUpdate/UpdateForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/MAutoUpdate/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | #Visual Studio LightSwitch
212 | _Pvt_Extensions/
213 | GeneratedArtifacts/
214 | ServiceConfiguration.cscfg
215 | ModelManifest.xml
216 | generated.parameters.xml
217 | ## TODO: Comment the next line if you want version controls the generated client .xap file
218 | *.Client.xap
219 |
220 | # Backup & report files from converting an old project file
221 | # to a newer Visual Studio version. Backup files are not needed,
222 | # because we have git ;-)
223 | _UpgradeReport_Files/
224 | Backup*/
225 | UpgradeLog*.XML
226 | UpgradeLog*.htm
227 |
228 | # SQL Server files
229 | *.mdf
230 | *.ldf
231 |
232 | # Business Intelligence projects
233 | *.rdl.data
234 | *.bim.layout
235 | *.bim_*.settings
236 |
237 | # Microsoft Fakes
238 | FakesAssemblies/
239 |
240 | # GhostDoc plugin setting file
241 | *.GhostDoc.xml
242 |
243 | # Node.js Tools for Visual Studio
244 | .ntvs_analysis.dat
245 | node_modules/
246 |
247 | # Typescript v1 declaration files
248 | typings/
249 |
250 | # Visual Studio 6 build log
251 | *.plg
252 |
253 | # Visual Studio 6 workspace options file
254 | *.opt
255 |
256 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
257 | *.vbw
258 |
259 | # Visual Studio LightSwitch build output
260 | **/*.HTMLClient/GeneratedArtifacts
261 | **/*.DesktopClient/GeneratedArtifacts
262 | **/*.DesktopClient/ModelManifest.xml
263 | **/*.Server/GeneratedArtifacts
264 | **/*.Server/ModelManifest.xml
265 | _Pvt_Extensions
266 |
267 | # Paket dependency manager
268 | .paket/paket.exe
269 | paket-files/
270 |
271 | # FAKE - F# Make
272 | .fake/
273 |
274 | # JetBrains Rider
275 | .idea/
276 | *.sln.iml
277 |
278 | # CodeRush
279 | .cr/
280 |
281 | # Python Tools for Visual Studio (PTVS)
282 | __pycache__/
283 | *.pyc
284 |
285 | # Mac crap
286 | .DS_Store
287 |
288 | # VisualStudioCode
289 | .vscode
290 |
291 | # Cake - Uncomment if you are using it
292 | # tools/**
293 | # !tools/packages.config
294 |
295 | /ModelCreate
296 | /GWebApi/photoImage
297 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipFile.x-IEnumerable.cs:
--------------------------------------------------------------------------------
1 | // ZipFile.x-IEnumerable.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2006, 2007, 2008, 2009 Dino Chiesa and Microsoft Corporation.
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2009-December-26 15:13:26>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines smoe methods for IEnumerable support. It is
23 | // particularly important for COM to have these things in a separate module.
24 | //
25 | // ------------------------------------------------------------------
26 |
27 |
28 | namespace Ionic.Zip
29 | {
30 |
31 | // For some weird reason, the method with the DispId(-4) attribute, which is used as
32 | // the _NewEnum() method, and which is required to get enumeration to work from COM
33 | // environments like VBScript and Javascript (etc) must be the LAST MEMBER in the
34 | // source. In the event of Partial classes, it needs to be the last member defined
35 | // in the last source module. The source modules are ordered alphabetically by
36 | // filename. Not sure why this is true. In any case, we put the enumeration stuff
37 | // here in this oddly-named module, for this reason.
38 | //
39 |
40 |
41 |
42 | public partial class ZipFile
43 | {
44 |
45 |
46 |
47 |
48 | ///
49 | /// Generic IEnumerator support, for use of a ZipFile in an enumeration.
50 | ///
51 | ///
52 | ///
53 | /// You probably do not want to call GetEnumerator explicitly. Instead
54 | /// it is implicitly called when you use a loop in C#, or a
55 | /// For Each loop in VB.NET.
56 | ///
57 | ///
58 | ///
59 | /// This example reads a zipfile of a given name, then enumerates the
60 | /// entries in that zip file, and displays the information about each
61 | /// entry on the Console.
62 | ///
63 | /// using (ZipFile zip = ZipFile.Read(zipfile))
64 | /// {
65 | /// bool header = true;
66 | /// foreach (ZipEntry e in zip)
67 | /// {
68 | /// if (header)
69 | /// {
70 | /// System.Console.WriteLine("Zipfile: {0}", zip.Name);
71 | /// System.Console.WriteLine("Version Needed: 0x{0:X2}", e.VersionNeeded);
72 | /// System.Console.WriteLine("BitField: 0x{0:X2}", e.BitField);
73 | /// System.Console.WriteLine("Compression Method: 0x{0:X2}", e.CompressionMethod);
74 | /// System.Console.WriteLine("\n{1,-22} {2,-6} {3,4} {4,-8} {0}",
75 | /// "Filename", "Modified", "Size", "Ratio", "Packed");
76 | /// System.Console.WriteLine(new System.String('-', 72));
77 | /// header = false;
78 | /// }
79 | ///
80 | /// System.Console.WriteLine("{1,-22} {2,-6} {3,4:F0}% {4,-8} {0}",
81 | /// e.FileName,
82 | /// e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
83 | /// e.UncompressedSize,
84 | /// e.CompressionRatio,
85 | /// e.CompressedSize);
86 | ///
87 | /// e.Extract();
88 | /// }
89 | /// }
90 | ///
91 | ///
92 | ///
93 | /// Dim ZipFileToExtract As String = "c:\foo.zip"
94 | /// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
95 | /// Dim header As Boolean = True
96 | /// Dim e As ZipEntry
97 | /// For Each e In zip
98 | /// If header Then
99 | /// Console.WriteLine("Zipfile: {0}", zip.Name)
100 | /// Console.WriteLine("Version Needed: 0x{0:X2}", e.VersionNeeded)
101 | /// Console.WriteLine("BitField: 0x{0:X2}", e.BitField)
102 | /// Console.WriteLine("Compression Method: 0x{0:X2}", e.CompressionMethod)
103 | /// Console.WriteLine(ChrW(10) & "{1,-22} {2,-6} {3,4} {4,-8} {0}", _
104 | /// "Filename", "Modified", "Size", "Ratio", "Packed" )
105 | /// Console.WriteLine(New String("-"c, 72))
106 | /// header = False
107 | /// End If
108 | /// Console.WriteLine("{1,-22} {2,-6} {3,4:F0}% {4,-8} {0}", _
109 | /// e.FileName, _
110 | /// e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"), _
111 | /// e.UncompressedSize, _
112 | /// e.CompressionRatio, _
113 | /// e.CompressedSize )
114 | /// e.Extract
115 | /// Next
116 | /// End Using
117 | ///
118 | ///
119 | ///
120 | /// A generic enumerator suitable for use within a foreach loop.
121 | public System.Collections.Generic.IEnumerator GetEnumerator()
122 | {
123 | foreach (ZipEntry e in _entries.Values)
124 | yield return e;
125 | }
126 |
127 | System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
128 | {
129 | return GetEnumerator();
130 | }
131 |
132 |
133 | ///
134 | /// An IEnumerator, for use of a ZipFile in a foreach construct.
135 | ///
136 | ///
137 | ///
138 | /// This method is included for COM support. An application generally does not call
139 | /// this method directly. It is called implicitly by COM clients when enumerating
140 | /// the entries in the ZipFile instance. In VBScript, this is done with a For Each
141 | /// statement. In Javascript, this is done with new Enumerator(zipfile).
142 | ///
143 | ///
144 | ///
145 | /// The IEnumerator over the entries in the ZipFile.
146 | ///
147 | [System.Runtime.InteropServices.DispId(-4)]
148 | public System.Collections.IEnumerator GetNewEnum() // the name of this method is not significant
149 | {
150 | return GetEnumerator();
151 | }
152 |
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/MAutoUpdate/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | using MAutoUpdate.Control;
2 |
3 | namespace MAutoUpdate
4 | {
5 | partial class MainForm
6 | {
7 | ///
8 | /// Required designer variable.
9 | ///
10 | private System.ComponentModel.IContainer components = null;
11 |
12 | ///
13 | /// Clean up any resources being used.
14 | ///
15 | /// true if managed resources should be disposed; otherwise, false.
16 | protected override void Dispose(bool disposing)
17 | {
18 | if (disposing && (components != null))
19 | {
20 | components.Dispose();
21 | }
22 | base.Dispose(disposing);
23 | }
24 |
25 | #region Windows Form Designer generated code
26 |
27 | ///
28 | /// Required method for Designer support - do not modify
29 | /// the contents of this method with the code editor.
30 | ///
31 | private void InitializeComponent()
32 | {
33 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
34 | this.LBTitle = new System.Windows.Forms.Label();
35 | this.lblContent = new System.Windows.Forms.Label();
36 | this.btnUpdateNow = new YButton();
37 | this.btnUpdateLater = new YButton();
38 | this.btnIgnore = new YButton();
39 | this.SuspendLayout();
40 | //
41 | // LBTitle
42 | //
43 | this.LBTitle.AutoSize = true;
44 | this.LBTitle.BackColor = System.Drawing.Color.Transparent;
45 | this.LBTitle.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Bold);
46 | this.LBTitle.ForeColor = System.Drawing.Color.DimGray;
47 | this.LBTitle.Location = new System.Drawing.Point(11, 13);
48 | this.LBTitle.Name = "LBTitle";
49 | this.LBTitle.Size = new System.Drawing.Size(54, 19);
50 | this.LBTitle.TabIndex = 22;
51 | this.LBTitle.Text = "新版本";
52 | //
53 | // lblContent
54 | //
55 | this.lblContent.Font = new System.Drawing.Font("微软雅黑", 11F);
56 | this.lblContent.ForeColor = System.Drawing.Color.DimGray;
57 | this.lblContent.Location = new System.Drawing.Point(112, 103);
58 | this.lblContent.Name = "lblContent";
59 | this.lblContent.Size = new System.Drawing.Size(358, 159);
60 | this.lblContent.TabIndex = 24;
61 | //
62 | // btnUpdateNow
63 | //
64 | this.btnUpdateNow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(173)))), ((int)(((byte)(25)))));
65 | this.btnUpdateNow.EnterImage = null;
66 | this.btnUpdateNow.Font = new System.Drawing.Font("微软雅黑", 10F);
67 | this.btnUpdateNow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
68 | this.btnUpdateNow.IsColorChange = true;
69 | this.btnUpdateNow.IsFontChange = false;
70 | this.btnUpdateNow.Location = new System.Drawing.Point(390, 332);
71 | this.btnUpdateNow.MoveColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(173)))), ((int)(((byte)(25)))));
72 | this.btnUpdateNow.MoveFontColor = System.Drawing.Color.White;
73 | this.btnUpdateNow.Name = "btnUpdateNow";
74 | this.btnUpdateNow.NormalColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(173)))), ((int)(((byte)(25)))));
75 | this.btnUpdateNow.NormalFontColor = System.Drawing.Color.White;
76 | this.btnUpdateNow.Size = new System.Drawing.Size(141, 45);
77 | this.btnUpdateNow.TabIndex = 27;
78 | this.btnUpdateNow.Text = "立即更新";
79 | this.btnUpdateNow.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
80 | this.btnUpdateNow.Click += new System.EventHandler(this.btnUpdateNow_Click);
81 | //
82 | // btnUpdateLater
83 | //
84 | this.btnUpdateLater.BackColor = System.Drawing.Color.White;
85 | this.btnUpdateLater.EnterImage = null;
86 | this.btnUpdateLater.Font = new System.Drawing.Font("微软雅黑", 10F);
87 | this.btnUpdateLater.ForeColor = System.Drawing.Color.Black;
88 | this.btnUpdateLater.IsColorChange = true;
89 | this.btnUpdateLater.IsFontChange = false;
90 | this.btnUpdateLater.Location = new System.Drawing.Point(232, 332);
91 | this.btnUpdateLater.MoveColor = System.Drawing.Color.White;
92 | this.btnUpdateLater.MoveFontColor = System.Drawing.Color.Black;
93 | this.btnUpdateLater.Name = "btnUpdateLater";
94 | this.btnUpdateLater.NormalColor = System.Drawing.Color.White;
95 | this.btnUpdateLater.NormalFontColor = System.Drawing.Color.Black;
96 | this.btnUpdateLater.Size = new System.Drawing.Size(141, 45);
97 | this.btnUpdateLater.TabIndex = 26;
98 | this.btnUpdateLater.Text = "以后提醒我";
99 | this.btnUpdateLater.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
100 | this.btnUpdateLater.Click += new System.EventHandler(this.btnUpdateLater_Click);
101 | //
102 | // btnIgnore
103 | //
104 | this.btnIgnore.BackColor = System.Drawing.Color.White;
105 | this.btnIgnore.EnterImage = null;
106 | this.btnIgnore.Font = new System.Drawing.Font("微软雅黑", 10F);
107 | this.btnIgnore.ForeColor = System.Drawing.Color.Black;
108 | this.btnIgnore.IsColorChange = true;
109 | this.btnIgnore.IsFontChange = false;
110 | this.btnIgnore.Location = new System.Drawing.Point(76, 332);
111 | this.btnIgnore.MoveColor = System.Drawing.Color.White;
112 | this.btnIgnore.MoveFontColor = System.Drawing.Color.Black;
113 | this.btnIgnore.Name = "btnIgnore";
114 | this.btnIgnore.NormalColor = System.Drawing.Color.White;
115 | this.btnIgnore.NormalFontColor = System.Drawing.Color.Black;
116 | this.btnIgnore.Size = new System.Drawing.Size(141, 45);
117 | this.btnIgnore.TabIndex = 25;
118 | this.btnIgnore.Text = "忽略这次更新";
119 | this.btnIgnore.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
120 | this.btnIgnore.Click += new System.EventHandler(this.btnIgnore_Click);
121 | //
122 | // MainForm
123 | //
124 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
125 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
126 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
127 | this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
128 | this.ClientSize = new System.Drawing.Size(600, 420);
129 | this.Controls.Add(this.btnUpdateNow);
130 | this.Controls.Add(this.btnUpdateLater);
131 | this.Controls.Add(this.btnIgnore);
132 | this.Controls.Add(this.lblContent);
133 | this.Controls.Add(this.LBTitle);
134 | this.DoubleBuffered = true;
135 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
136 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
137 | this.Name = "MainForm";
138 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
139 | this.Text = "MainForm";
140 | this.TopMost = true;
141 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PNTop_MouseDown);
142 | this.ResumeLayout(false);
143 | this.PerformLayout();
144 |
145 | }
146 |
147 | #endregion
148 | private System.Windows.Forms.Label LBTitle;
149 | private System.Windows.Forms.Label lblContent;
150 | private YButton btnIgnore;
151 | private YButton btnUpdateLater;
152 | private YButton btnUpdateNow;
153 | }
154 | }
--------------------------------------------------------------------------------
/MAutoUpdate/MAutoUpdate.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.30729
7 | 2.0
8 | {A41F9740-A368-4F0C-91CE-ACF24D0DCA60}
9 | WinExe
10 | Properties
11 | MAutoUpdate
12 | MAutoUpdate
13 | v2.0
14 | 512
15 |
16 |
17 |
18 |
19 | 3.5
20 | 发布\
21 | true
22 | Disk
23 | false
24 | Foreground
25 | 7
26 | Days
27 | false
28 | false
29 | true
30 | 0
31 | 1.0.0.%2a
32 | false
33 | false
34 | true
35 |
36 |
37 |
38 | true
39 | full
40 | false
41 | bin\Debug\
42 | DEBUG;TRACE
43 | prompt
44 | 4
45 | true
46 |
47 |
48 | pdbonly
49 | true
50 | bin\Release\
51 | TRACE
52 | prompt
53 | 4
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | Form
77 |
78 |
79 | MainForm.cs
80 |
81 |
82 |
83 |
84 | True
85 | True
86 | Resources.resx
87 |
88 |
89 |
90 | Form
91 |
92 |
93 | UpdateForm.cs
94 |
95 |
96 | Component
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 | MainForm.cs
145 |
146 |
147 | ResXFileCodeGenerator
148 | Designer
149 | Resources.Designer.cs
150 |
151 |
152 | UpdateForm.cs
153 |
154 |
155 |
156 |
157 | SettingsSingleFileGenerator
158 | Settings.Designer.cs
159 |
160 |
161 | True
162 | Settings.settings
163 | True
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 | PreserveNewest
172 |
173 |
174 |
175 |
176 |
177 | False
178 | .NET Framework 3.5 SP1 Client Profile
179 | false
180 |
181 |
182 | False
183 | .NET Framework 3.5 SP1
184 | true
185 |
186 |
187 |
188 |
189 |
190 |
191 |
198 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/Exceptions.cs:
--------------------------------------------------------------------------------
1 | // Exceptions.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2008, 2009 Dino Chiesa and Microsoft Corporation.
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2011-July-12 12:19:10>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines exceptions used in the class library.
23 | //
24 |
25 |
26 |
27 | using System;
28 | using System.Collections.Generic;
29 | using System.Text;
30 | #if !NETCF
31 | using System.Runtime.Serialization;
32 | #endif
33 |
34 | namespace Ionic.Zip
35 | {
36 | /////
37 | ///// Base exception type for all custom exceptions in the Zip library. It acts as a marker class.
38 | /////
39 | //[AttributeUsage(AttributeTargets.Class)]
40 | //public class ZipExceptionAttribute : Attribute { }
41 |
42 |
43 |
44 | ///
45 | /// Issued when an ZipEntry.ExtractWithPassword() method is invoked
46 | /// with an incorrect password.
47 | ///
48 | #if !SILVERLIGHT
49 | [Serializable]
50 | #endif
51 | [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000B")]
52 | public class BadPasswordException : ZipException
53 | {
54 | ///
55 | /// Default ctor.
56 | ///
57 | public BadPasswordException() { }
58 |
59 | ///
60 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
61 | ///
62 | /// The message in the exception.
63 | public BadPasswordException(String message)
64 | : base(message)
65 | { }
66 |
67 | ///
68 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
69 | ///
70 | /// The message in the exception.
71 | /// The innerException for this exception.
72 | public BadPasswordException(String message, Exception innerException)
73 | : base(message, innerException)
74 | {
75 | }
76 |
77 |
78 | #if ! (NETCF || SILVERLIGHT)
79 | ///
80 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
81 | ///
82 | /// The serialization info for the exception.
83 | /// The streaming context from which to deserialize.
84 | protected BadPasswordException(SerializationInfo info, StreamingContext context)
85 | : base(info, context)
86 | { }
87 | #endif
88 |
89 | }
90 |
91 | ///
92 | /// Indicates that a read was attempted on a stream, and bad or incomplete data was
93 | /// received.
94 | ///
95 | #if !SILVERLIGHT
96 | [Serializable]
97 | #endif
98 | [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000A")]
99 | public class BadReadException : ZipException
100 | {
101 | ///
102 | /// Default ctor.
103 | ///
104 | public BadReadException() { }
105 |
106 | ///
107 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
108 | ///
109 | /// The message in the exception.
110 | public BadReadException(String message)
111 | : base(message)
112 | { }
113 |
114 | ///
115 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
116 | ///
117 | /// The message in the exception.
118 | /// The innerException for this exception.
119 | public BadReadException(String message, Exception innerException)
120 | : base(message, innerException)
121 | {
122 | }
123 |
124 | #if ! (NETCF || SILVERLIGHT)
125 | ///
126 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
127 | ///
128 | /// The serialization info for the exception.
129 | /// The streaming context from which to deserialize.
130 | protected BadReadException(SerializationInfo info, StreamingContext context)
131 | : base(info, context)
132 | { }
133 | #endif
134 |
135 | }
136 |
137 |
138 |
139 | ///
140 | /// Issued when an CRC check fails upon extracting an entry from a zip archive.
141 | ///
142 | #if !SILVERLIGHT
143 | [Serializable]
144 | #endif
145 | [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00009")]
146 | public class BadCrcException : ZipException
147 | {
148 | ///
149 | /// Default ctor.
150 | ///
151 | public BadCrcException() { }
152 |
153 | ///
154 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
155 | ///
156 | /// The message in the exception.
157 | public BadCrcException(String message)
158 | : base(message)
159 | { }
160 |
161 |
162 | #if ! (NETCF || SILVERLIGHT)
163 | ///
164 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
165 | ///
166 | /// The serialization info for the exception.
167 | /// The streaming context from which to deserialize.
168 | protected BadCrcException(SerializationInfo info, StreamingContext context)
169 | : base(info, context)
170 | { }
171 | #endif
172 |
173 | }
174 |
175 |
176 | ///
177 | /// Issued when errors occur saving a self-extracting archive.
178 | ///
179 | #if !SILVERLIGHT
180 | [Serializable]
181 | #endif
182 | [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00008")]
183 | public class SfxGenerationException : ZipException
184 | {
185 | ///
186 | /// Default ctor.
187 | ///
188 | public SfxGenerationException() { }
189 |
190 | ///
191 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
192 | ///
193 | /// The message in the exception.
194 | public SfxGenerationException(String message)
195 | : base(message)
196 | { }
197 |
198 | #if ! (NETCF || SILVERLIGHT)
199 | ///
200 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
201 | ///
202 | /// The serialization info for the exception.
203 | /// The streaming context from which to deserialize.
204 | protected SfxGenerationException(SerializationInfo info, StreamingContext context)
205 | : base(info, context)
206 | { }
207 | #endif
208 |
209 | }
210 |
211 |
212 | ///
213 | /// Indicates that an operation was attempted on a ZipFile which was not possible
214 | /// given the state of the instance. For example, if you call Save() on a ZipFile
215 | /// which has no filename set, you can get this exception.
216 | ///
217 | #if !SILVERLIGHT
218 | [Serializable]
219 | #endif
220 | [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00007")]
221 | public class BadStateException : ZipException
222 | {
223 | ///
224 | /// Default ctor.
225 | ///
226 | public BadStateException() { }
227 |
228 | ///
229 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
230 | ///
231 | /// The message in the exception.
232 | public BadStateException(String message)
233 | : base(message)
234 | { }
235 |
236 | ///
237 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
238 | ///
239 | /// The message in the exception.
240 | /// The innerException for this exception.
241 | public BadStateException(String message, Exception innerException)
242 | : base(message, innerException)
243 | {}
244 |
245 | #if ! (NETCF || SILVERLIGHT)
246 | ///
247 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
248 | ///
249 | /// The serialization info for the exception.
250 | /// The streaming context from which to deserialize.
251 | protected BadStateException(SerializationInfo info, StreamingContext context)
252 | : base(info, context)
253 | { }
254 | #endif
255 |
256 | }
257 |
258 | ///
259 | /// Base class for all exceptions defined by and throw by the Zip library.
260 | ///
261 | #if !SILVERLIGHT
262 | [Serializable]
263 | #endif
264 | [System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00006")]
265 | public class ZipException : Exception
266 | {
267 | ///
268 | /// Default ctor.
269 | ///
270 | public ZipException() { }
271 |
272 | ///
273 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
274 | ///
275 | /// The message in the exception.
276 | public ZipException(String message) : base(message) { }
277 |
278 | ///
279 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
280 | ///
281 | /// The message in the exception.
282 | /// The innerException for this exception.
283 | public ZipException(String message, Exception innerException)
284 | : base(message, innerException)
285 | { }
286 |
287 | #if ! (NETCF || SILVERLIGHT)
288 | ///
289 | /// Come on, you know how exceptions work. Why are you looking at this documentation?
290 | ///
291 | /// The serialization info for the exception.
292 | /// The streaming context from which to deserialize.
293 | protected ZipException(SerializationInfo info, StreamingContext context)
294 | : base(info, context)
295 | { }
296 | #endif
297 |
298 | }
299 |
300 | }
301 |
--------------------------------------------------------------------------------
/MAutoUpdate/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 |
123 | AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAgBAAAAAAAAAAAAAAAAAAAAAA
124 | AAAAAAAAAAAAAMC6qBr58dmS+fHZ4Pnx2f358dn/+fHZ//nx2f/58dn/+fHZ//nx2f/58dn/+fHZ//nx
125 | 2f/58dn/+fHZ//nx2f/58dn/+fHZ//nx2f/58dn/+fLc//379f/79ub/+fHZ//nx2f358dnf+fHZksjC
126 | rxoAAAAAAAAAAAAAAADm4Ms9+fLb7vny2//58tv/+fLb//ny2//58tv/+fLb//ny2//48Nf/8OS//+jZ
127 | p//x5cL/+fLb//ny2//58tv/+fLb//ny2//58tv/+fLb//r04f/+/fr///////7+/v/8+Oz/+fLb//ny
128 | 2//58tv/+fLb7uzl0D0AAAAAwLurGvnz3e75893/+fPd//nz3f/5893/+fPd//nz3f/5893/+fPd/+DM
129 | j/++mST/vpkk/8ioRP/48Nj/+fPd//nz3f/f0Jj/8erL//nz3f/79ub//v78///////39vX/////////
130 | ///9+vL/+fPe//nz3f/5893/+fPd7s7JuBr69OCS+vTg//r04P/69OD/+vTg//r04P/48dz/+vTg//r0
131 | 4P/06s3/zrFX/76ZJP++mST/vpkk/8CgN//JsFj/zLZi/7KXJf+kmyv/5ePD//7+/v//////2dHO/2lI
132 | Pf+bhn7/+vn5///////9/Pf/+vTi//r04P/69OD/+vPgkvr14+D69eP/+vXj//r14//69eP/59in/8Cd
133 | LP/QtF7/1r1v/7+bKP++mST/vpkk/76ZJP++mST/upgm/7eYJv+2mCb/s5go/9bRnv/+/v7//v7+/7qr
134 | pv9cOSv/WDQm/1g0Jv99YVb/7enn///////+/fr/+/bn//r14//69ePg+/bn/fv25//79uf/+/bn/+rc
135 | sP+/myn/vpkk/76ZJP++mST/vpkk/76ZJP++mST/wZ4w/8mpR//DpkT/uZor/7qdMP/p4L7///////n4
136 | 9/+YgXj/WTUm/1k1Jv9ZNSb/WTUm/1k1Jv9oRzr/1s3K///////+/vz//Pjs//v25/379+r/+/fq//v3
137 | 6v/79+r/5dWj/72YJP+9mCT/vZgk/72YJP+9mCT/0LZh/+3hu//79uj/+/fq//v36v/69ef/9/Pn////
138 | ///q5uT/e15R/1o1Jv9aNSb/WjUm/1o1Jv9aNSb/WjUm/1o1Jv9dOSr/tqag//7+/v/+/v7//Prx//z4
139 | 7f/8+O3//Pjt//z47f/48uL/u5Mq/7qRJv+6kSb/vJQr/+TTpP/8+O3//Pjt//z47f/8+O3//Prx//7+
140 | /f//////08nF/2hGN/9bNib/WzYm/1s2Jv9bNib/WzYm/1s2Jv9bNib/WzYm/1s2Jv9bNib/lX1y//j2
141 | 9v/+/v7//Prx//z68f/8+vH//Prx/9i/i/+2hyj/toco/7aIKv/n17T//Prx//z68f/8+vH//Prx//37
142 | 9f/+/v7//v7+/7Oimv9eOin/XDcm/1w3Jv9cNyb/XDcm/1w3Jv9cNyb/XDcm/1w3Jv9cNyb/XDcm/1w3
143 | Jv9cNyb/eltN/+jj4f/9+/T//fv0//379P/z6tr/toY3/7F+K/+xfiv/0LF8//379P/9+/T//fv0//X2
144 | 9P/5+vn//v7+///////v6+r/yr64/8q+uP/Kvrj/yr64/8q+uP96W03/Xjgm/144Jv9eOCb/Xjgm/6uY
145 | j//Kvrj/yr64/8q+uP/Kvrj/1cvH//389//v5NT/vI5U/611Lv+tdS3/rXUt/612L//07N///fz3//38
146 | 9//9/Pf/5/D6/////////////////////////////////////////////////4ltYP9fOSb/Xzkm/185
147 | Jv9fOSb/0cfB/////////////////////////////v36/9vBqP+naDD/p2gw/6doMP+naDD/u4pe//79
148 | +v/+/fr//v36/8vg9/9WnfD/v9n3//79+//+/fv//fz7/62S7v/8+/v//v79////////////i25g/2E6
149 | Jv9hOib/YTom/2E6Jv/Sx8H///////7+/v/+/fv//v37//79+//+/vz/y6ON/6FaNP+hWjT/oVo0/6Fa
150 | NP/LpI7//v78//7+/P/+/fz/LpLt/yeN7P/8/Pz//v78/+Tf8//+/fz/nXns//79/P/+/v7/////////
151 | //+Mb2D/Yzsm/2M7Jv9jOyb/Yzsm/9LHwf///////v7+//7+/P/+/vz//v78//7+/v/avbP/oVdD/5tM
152 | N/+bTDf/m0w3/9CroP/+/v7//v7+//7+/v+Z0/b/N6rv//7+/v/+/v7/2sz4/7SW8//e0fn//v7+//7+
153 | /v///////////41vYP9lPCb/ZTwm/2U8Jv9lPCb/08fB///////+/v7//v7+//7+/v/+/v7/////////
154 | ///38fD/nExF/5ZBOf+WQTn/yJyY/////////////////3XR9f8WsO7/4fX8////////////////////
155 | ////////////////////////j3Bg/2Y9Jv9nPSb/Zj0m/2Y9Jv/TyMH/////////////////////////
156 | //////////////////+mXln/lkA6/5ZAOv+2enb/////////////////XMzz/xS27v9OyPL/8/v+////
157 | ///////////////////3+PH///////////+QcWD/aD4m/2g+Jv9oPib/aD4m/9TIwf//////////////
158 | /////////////////////////////7Z6dv+WQDr/lkA6/5tJRP/69/f////////////4/f7/xO36/xe8
159 | 7v8yxPD/leD1/7zo7f+z3dT/irqJ/8fXsP///////////5JyYP9qPyb/aj8m/2o/Jv9qPyb/1cjB////
160 | ///////////////////////////////////59PT/pFpV/5ZAOv+WQDr/lkA6/9Sxrv//////////////
161 | ////////KcLw/xS87v8Vu+3/HLng/zOyt/9Lqor/wdzG////////////k3Jg/2xAJv9sQCb/bEAm/2xA
162 | Jv/VycH//////////////////////////////////////7qCfv+WQDr/lkA6/5ZAOv+WQDr/oFJN//fx
163 | 8P/////////////////V8/z/qOb5/9fz/P9b0PP/HLnh/4fT2f/+/v7///////////+Vc2D/bkEm/25B
164 | Jv9uQSb/bkEm/9bJwf//////////////////////////////////////tXl1/5ZAOv+WQDr/lkA6/5ZA
165 | Ov+WQDr/snNv//z5+f////////////////////////////D6/f/M8Pv/7vr8/////////////////5Z0
166 | X/9wQib/cEIm/3BCJv9wQib/1snB/////////////////////////////v7+//7+/v/p19X/lkA6/5ZA
167 | Ov+WQDr/lkA6/5ZAOv+WPzv/sXFz//fw8f/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7///7+////
168 | ////////l3Vg/3JDJv9yQyb/ckMm/3JDJv/XycH///////7//v/+/v7//v7+//7+/v/+/v7//v7+//7+
169 | /v+9iIT/s3Vx/7h+ev+WQDr/lkA6/5Y/O/+VPkL/nlBb/9a0vf/8+vv//v7+//7+/v/+/v7//v7+//7+
170 | /v/+/v7///////////+ZdV//dEQm/3REJv90RCb/dEQm/9fKwf///////v7+//7+/v/+/v7//v7+//7+
171 | /v/+/v7//v7+//7+/v/+/v7//v7+/8OTkP+WQDr/lj87/5U+Qv+UPUr/kztS/5xLaf+8hp//07DE/97D
172 | 1f/dw9j/07DP/+bT5f///////////5p2X/92RSb/dkUm/3ZFJv92RSb/2MrB///////+/v7//v7+//7+
173 | /v/+/v7//f39//39/f/9/f3//f39//39/f/9/f3//fz8/8KRjf+WPzv/lT5C/5Q9Sv+TO1L/kjpa/5I5
174 | Y/+RN2v/kDZz/480e/+OM4P/0KvP////////////m3df/3dGJv93Rib/d0Ym/3dGJv/YysH///////7+
175 | /v/9/f3//f39//39/f/9/f3//f39//39/f/9/f3//f39//39/f/9/f3/38XE/5Y/O/+VPkL/lD1K/5M7
176 | Uv+SOlr/kjlj/5E3a/+QNnP/jzR7/44zg//Qq8////////////+cd1//eUYm/3lGJv95Rib/eUYm/9nK
177 | wf///////v7+//39/f/9/f3//f39//z8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8/P/bv73/lj87/5U+
178 | Qv+UPUr/kztS/5I6Wv+SOWP/kTdr/5A2c/+PNHv/jjOD/9Crz////////////514X/96Ryb/ekcm/3pH
179 | Jv96Ryb/2cvB///////+/v7//Pz8//z8/P/8/Pz//Pz8/fz8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//Dm
180 | 5f+2enf/lT9C/5Q9Sv+VP1X/zaWz/8WXrf+wcJX/oVWJ/480e/+OM4P/0KvP////////////nnhf/3tI
181 | Jv97SCb/e0gm/3tIJv/Zy8H///////7+/v/8/Pz//Pz8//z8/P37+/vg+/v7//v7+//7+/v/+/v7//v7
182 | +//7+/v/+/v7//v7+//l09T/sXJ8/9vAx//7+/v/+/v7//v7+//6+Pn/qGOZ/44zg//Qq8//////////
183 | //+feF//fEgm/3xIJv98SCb/fEgm/9rLwf///////v7+//v7+//7+/v/+/v74Pv7+5L7+/v/+/v7//v7
184 | +//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//u4+z/lkGM/9Sx
185 | 0v/////////////////////////////////////////////////+/v7/+/v7//v7+//7+/uSycnJGvr6
186 | +u76+vr/+vr6//r6+v/6+vr/+vr6//r6+v/6+vr/+vr6//r6+v/6+vr/+vr6//r6+v/6+vr/+vr6//r6
187 | +v/5+Pn//f39//////////////////////////////////////////////////7+/v/6+vr/+vr67tbW
188 | 1hoAAAAA7e3tPfr6+u36+vr/+vr6//r6+v/6+vr/+vr6//r6+v/6+vr/+vr6//r6+v/6+vr/+vr6//r6
189 | +v/6+vr/+vr6//r6+v/7+/v//Pz8//z8/P/8/Pz//Pz8//z8/P/8/Pz//Pz8//z8/P/8/Pz/+/v7//r6
190 | +u3y8vI9AAAAAAAAAAAAAAAAz8/PGvr5+ZL5+frf+vr5/Pr6+v/6+vr/+fr6//r6+v/5+fr/+vr6//r6
191 | +v/5+vr/+vn6//r6+f/6+vr/+vr6//r6+f/6+vr/+vr6//r6+v/6+vn/+vr6//r6+v/6+vr/+vr6/Pn5
192 | +d/6+fmS1dXVGgAAAAAAAAAAwAAAA4AAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
193 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
194 | AAAAAAAAAAAAAAAAAAAAAAAAgAAAAcAAAAM=
195 |
196 |
197 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipFile.Extract.cs:
--------------------------------------------------------------------------------
1 | // ZipFile.Extract.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009 Dino Chiesa.
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2011-July-31 14:45:18>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines the methods for Extract operations on zip files.
23 | //
24 | // ------------------------------------------------------------------
25 | //
26 |
27 |
28 | using System;
29 | using System.IO;
30 | using System.Collections.Generic;
31 |
32 | namespace Ionic.Zip
33 | {
34 |
35 | public partial class ZipFile
36 | {
37 |
38 | ///
39 | /// Extracts all of the items in the zip archive, to the specified path in the
40 | /// filesystem. The path can be relative or fully-qualified.
41 | ///
42 | ///
43 | ///
44 | ///
45 | /// This method will extract all entries in the ZipFile to the
46 | /// specified path.
47 | ///
48 | ///
49 | ///
50 | /// If an extraction of a file from the zip archive would overwrite an
51 | /// existing file in the filesystem, the action taken is dictated by the
52 | /// ExtractExistingFile property, which overrides any setting you may have
53 | /// made on individual ZipEntry instances. By default, if you have not
54 | /// set that property on the ZipFile instance, the entry will not
55 | /// be extracted, the existing file will not be overwritten and an
56 | /// exception will be thrown. To change this, set the property, or use the
57 | /// overload that allows you to
59 | /// specify an ExtractExistingFileAction parameter.
60 | ///
61 | ///
62 | ///
63 | /// The action to take when an extract would overwrite an existing file
64 | /// applies to all entries. If you want to set this on a per-entry basis,
65 | /// then you must use one of the ZipEntry.Extract methods.
67 | ///
68 | ///
69 | ///
70 | /// This method will send verbose output messages to the , if it is set on the ZipFile
72 | /// instance.
73 | ///
74 | ///
75 | ///
76 | /// You may wish to take advantage of the ExtractProgress event.
77 | ///
78 | ///
79 | ///
80 | /// About timestamps: When extracting a file entry from a zip archive, the
81 | /// extracted file gets the last modified time of the entry as stored in
82 | /// the archive. The archive may also store extended file timestamp
83 | /// information, including last accessed and created times. If these are
84 | /// present in the ZipEntry, then the extracted file will also get
85 | /// these times.
86 | ///
87 | ///
88 | ///
89 | /// A Directory entry is somewhat different. It will get the times as
90 | /// described for a file entry, but, if there are file entries in the zip
91 | /// archive that, when extracted, appear in the just-created directory,
92 | /// then when those file entries are extracted, the last modified and last
93 | /// accessed times of the directory will change, as a side effect. The
94 | /// result is that after an extraction of a directory and a number of
95 | /// files within the directory, the last modified and last accessed
96 | /// timestamps on the directory will reflect the time that the last file
97 | /// was extracted into the directory, rather than the time stored in the
98 | /// zip archive for the directory.
99 | ///
100 | ///
101 | ///
102 | /// To compensate, when extracting an archive with ExtractAll,
103 | /// DotNetZip will extract all the file and directory entries as described
104 | /// above, but it will then make a second pass on the directories, and
105 | /// reset the times on the directories to reflect what is stored in the
106 | /// zip archive.
107 | ///
108 | ///
109 | ///
110 | /// This compensation is performed only within the context of an
111 | /// ExtractAll. If you call ZipEntry.Extract on a directory
112 | /// entry, the timestamps on directory in the filesystem will reflect the
113 | /// times stored in the zip. If you then call ZipEntry.Extract on
114 | /// a file entry, which is extracted into the directory, the timestamps on
115 | /// the directory will be updated to the current time.
116 | ///
117 | ///
118 | ///
119 | ///
120 | /// This example extracts all the entries in a zip archive file, to the
121 | /// specified target directory. The extraction will overwrite any
122 | /// existing files silently.
123 | ///
124 | ///
125 | /// String TargetDirectory= "unpack";
126 | /// using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
127 | /// {
128 | /// zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently;
129 | /// zip.ExtractAll(TargetDirectory);
130 | /// }
131 | ///
132 | ///
133 | ///
134 | /// Dim TargetDirectory As String = "unpack"
135 | /// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
136 | /// zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently
137 | /// zip.ExtractAll(TargetDirectory)
138 | /// End Using
139 | ///
140 | ///
141 | ///
142 | ///
143 | ///
144 | ///
145 | ///
146 | /// The path to which the contents of the zipfile will be extracted.
147 | /// The path can be relative or fully-qualified.
148 | ///
149 | ///
150 | public void ExtractAll(string path)
151 | {
152 | _InternalExtractAll(path, true);
153 | }
154 |
155 |
156 |
157 | ///
158 | /// Extracts all of the items in the zip archive, to the specified path in the
159 | /// filesystem, using the specified behavior when extraction would overwrite an
160 | /// existing file.
161 | ///
162 | ///
163 | ///
164 | ///
165 | ///
166 | /// This method will extract all entries in the ZipFile to the specified
167 | /// path. For an extraction that would overwrite an existing file, the behavior
168 | /// is dictated by , which overrides any
169 | /// setting you may have made on individual ZipEntry instances.
170 | ///
171 | ///
172 | ///
173 | /// The action to take when an extract would overwrite an existing file
174 | /// applies to all entries. If you want to set this on a per-entry basis,
175 | /// then you must use or one of the similar methods.
177 | ///
178 | ///
179 | ///
180 | /// Calling this method is equivalent to setting the property and then calling .
183 | ///
184 | ///
185 | ///
186 | /// This method will send verbose output messages to the
187 | /// , if it is set on the ZipFile instance.
188 | ///
189 | ///
190 | ///
191 | ///
192 | /// This example extracts all the entries in a zip archive file, to the
193 | /// specified target directory. It does not overwrite any existing files.
194 | ///
195 | /// String TargetDirectory= "c:\\unpack";
196 | /// using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
197 | /// {
198 | /// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite);
199 | /// }
200 | ///
201 | ///
202 | ///
203 | /// Dim TargetDirectory As String = "c:\unpack"
204 | /// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
205 | /// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite)
206 | /// End Using
207 | ///
208 | ///
209 | ///
210 | ///
211 | /// The path to which the contents of the zipfile will be extracted.
212 | /// The path can be relative or fully-qualified.
213 | ///
214 | ///
215 | ///
216 | /// The action to take if extraction would overwrite an existing file.
217 | ///
218 | ///
219 | public void ExtractAll(string path, ExtractExistingFileAction extractExistingFile)
220 | {
221 | ExtractExistingFile = extractExistingFile;
222 | _InternalExtractAll(path, true);
223 | }
224 |
225 |
226 | private void _InternalExtractAll(string path, bool overrideExtractExistingProperty)
227 | {
228 | bool header = Verbose;
229 | _inExtractAll = true;
230 | try
231 | {
232 | OnExtractAllStarted(path);
233 |
234 | int n = 0;
235 | foreach (ZipEntry e in _entries.Values)
236 | {
237 | if (header)
238 | {
239 | StatusMessageTextWriter.WriteLine("\n{1,-22} {2,-8} {3,4} {4,-8} {0}",
240 | "Name", "Modified", "Size", "Ratio", "Packed");
241 | StatusMessageTextWriter.WriteLine(new System.String('-', 72));
242 | header = false;
243 | }
244 | if (Verbose)
245 | {
246 | StatusMessageTextWriter.WriteLine("{1,-22} {2,-8} {3,4:F0}% {4,-8} {0}",
247 | e.FileName,
248 | e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
249 | e.UncompressedSize,
250 | e.CompressionRatio,
251 | e.CompressedSize);
252 | if (!String.IsNullOrEmpty(e.Comment))
253 | StatusMessageTextWriter.WriteLine(" Comment: {0}", e.Comment);
254 | }
255 | e.Password = _Password; // this may be null
256 | OnExtractEntry(n, true, e, path);
257 | if (overrideExtractExistingProperty)
258 | e.ExtractExistingFile = this.ExtractExistingFile;
259 | e.Extract(path);
260 | n++;
261 | OnExtractEntry(n, false, e, path);
262 | if (_extractOperationCanceled)
263 | break;
264 | }
265 |
266 | if (!_extractOperationCanceled)
267 | {
268 | // workitem 8264:
269 | // now, set times on directory entries, again.
270 | // The problem is, extracting a file changes the times on the parent
271 | // directory. So after all files have been extracted, we have to
272 | // run through the directories again.
273 | foreach (ZipEntry e in _entries.Values)
274 | {
275 | // check if it is a directory
276 | if ((e.IsDirectory) || (e.FileName.EndsWith("/")))
277 | {
278 | string outputFile = (e.FileName.StartsWith("/"))
279 | ? Path.Combine(path, e.FileName.Substring(1))
280 | : Path.Combine(path, e.FileName);
281 |
282 | e._SetTimes(outputFile, false);
283 | }
284 | }
285 | OnExtractAllCompleted(path);
286 | }
287 |
288 | }
289 | finally
290 | {
291 |
292 | _inExtractAll = false;
293 | }
294 | }
295 |
296 |
297 | }
298 | }
299 |
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipFile.Check.cs:
--------------------------------------------------------------------------------
1 | // ZipFile.Check.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2009-2011 Dino Chiesa.
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2011-July-31 14:40:50>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines the methods for doing Checks on zip files.
23 | // These are not necessary to include in the Reduced or CF
24 | // version of the library.
25 | //
26 | // ------------------------------------------------------------------
27 | //
28 |
29 |
30 | using System;
31 | using System.IO;
32 | using System.Collections.Generic;
33 |
34 | namespace Ionic.Zip
35 | {
36 | public partial class ZipFile
37 | {
38 | ///
39 | /// Checks a zip file to see if its directory is consistent.
40 | ///
41 | ///
42 | ///
43 | ///
44 | ///
45 | /// In cases of data error, the directory within a zip file can get out
46 | /// of synch with the entries in the zip file. This method checks the
47 | /// given zip file and returns true if this has occurred.
48 | ///
49 | ///
50 | /// This method may take a long time to run for large zip files.
51 | ///
52 | ///
53 | /// This method is not supported in the Reduced or Compact Framework
54 | /// versions of DotNetZip.
55 | ///
56 | ///
57 | ///
58 | /// Developers using COM can use the ComHelper.CheckZip(String)
60 | /// method.
61 | ///
62 | ///
63 | ///
64 | ///
65 | /// The filename to of the zip file to check.
66 | ///
67 | /// true if the named zip file checks OK. Otherwise, false.
68 | ///
69 | ///
70 | ///
71 | public static bool CheckZip(string zipFileName)
72 | {
73 | return CheckZip(zipFileName, false, null);
74 | }
75 |
76 |
77 | ///
78 | /// Checks a zip file to see if its directory is consistent,
79 | /// and optionally fixes the directory if necessary.
80 | ///
81 | ///
82 | ///
83 | ///
84 | ///
85 | /// In cases of data error, the directory within a zip file can get out of
86 | /// synch with the entries in the zip file. This method checks the given
87 | /// zip file, and returns true if this has occurred. It also optionally
88 | /// fixes the zipfile, saving the fixed copy in Name_Fixed.zip.
89 | ///
90 | ///
91 | ///
92 | /// This method may take a long time to run for large zip files. It
93 | /// will take even longer if the file actually needs to be fixed, and if
94 | /// fixIfNecessary is true.
95 | ///
96 | ///
97 | ///
98 | /// This method is not supported in the Reduced or Compact
99 | /// Framework versions of DotNetZip.
100 | ///
101 | ///
102 | ///
103 | ///
104 | /// The filename to of the zip file to check.
105 | ///
106 | /// If true, the method will fix the zip file if
107 | /// necessary.
108 | ///
109 | ///
110 | /// a TextWriter in which messages generated while checking will be written.
111 | ///
112 | ///
113 | /// true if the named zip is OK; false if the file needs to be fixed.
114 | ///
115 | ///
116 | ///
117 | public static bool CheckZip(string zipFileName, bool fixIfNecessary,
118 | TextWriter writer)
119 |
120 | {
121 | ZipFile zip1 = null, zip2 = null;
122 | bool isOk = true;
123 | try
124 | {
125 | zip1 = new ZipFile();
126 | zip1.FullScan = true;
127 | zip1.Initialize(zipFileName);
128 |
129 | zip2 = ZipFile.Read(zipFileName);
130 |
131 | foreach (var e1 in zip1)
132 | {
133 | foreach (var e2 in zip2)
134 | {
135 | if (e1.FileName == e2.FileName)
136 | {
137 | if (e1._RelativeOffsetOfLocalHeader != e2._RelativeOffsetOfLocalHeader)
138 | {
139 | isOk = false;
140 | if (writer != null)
141 | writer.WriteLine("{0}: mismatch in RelativeOffsetOfLocalHeader (0x{1:X16} != 0x{2:X16})",
142 | e1.FileName, e1._RelativeOffsetOfLocalHeader,
143 | e2._RelativeOffsetOfLocalHeader);
144 | }
145 | if (e1._CompressedSize != e2._CompressedSize)
146 | {
147 | isOk = false;
148 | if (writer != null)
149 | writer.WriteLine("{0}: mismatch in CompressedSize (0x{1:X16} != 0x{2:X16})",
150 | e1.FileName, e1._CompressedSize,
151 | e2._CompressedSize);
152 | }
153 | if (e1._UncompressedSize != e2._UncompressedSize)
154 | {
155 | isOk = false;
156 | if (writer != null)
157 | writer.WriteLine("{0}: mismatch in UncompressedSize (0x{1:X16} != 0x{2:X16})",
158 | e1.FileName, e1._UncompressedSize,
159 | e2._UncompressedSize);
160 | }
161 | if (e1.CompressionMethod != e2.CompressionMethod)
162 | {
163 | isOk = false;
164 | if (writer != null)
165 | writer.WriteLine("{0}: mismatch in CompressionMethod (0x{1:X4} != 0x{2:X4})",
166 | e1.FileName, e1.CompressionMethod,
167 | e2.CompressionMethod);
168 | }
169 | if (e1.Crc != e2.Crc)
170 | {
171 | isOk = false;
172 | if (writer != null)
173 | writer.WriteLine("{0}: mismatch in Crc32 (0x{1:X4} != 0x{2:X4})",
174 | e1.FileName, e1.Crc,
175 | e2.Crc);
176 | }
177 |
178 | // found a match, so stop the inside loop
179 | break;
180 | }
181 | }
182 | }
183 |
184 | zip2.Dispose();
185 | zip2 = null;
186 |
187 | if (!isOk && fixIfNecessary)
188 | {
189 | string newFileName = Path.GetFileNameWithoutExtension(zipFileName);
190 | newFileName = System.String.Format("{0}_fixed.zip", newFileName);
191 | zip1.Save(newFileName);
192 | }
193 | }
194 | finally
195 | {
196 | if (zip1 != null) zip1.Dispose();
197 | if (zip2 != null) zip2.Dispose();
198 | }
199 | return isOk;
200 | }
201 |
202 |
203 |
204 | ///
205 | /// Rewrite the directory within a zipfile.
206 | ///
207 | ///
208 | ///
209 | ///
210 | ///
211 | /// In cases of data error, the directory in a zip file can get out of
212 | /// synch with the entries in the zip file. This method attempts to fix
213 | /// the zip file if this has occurred.
214 | ///
215 | ///
216 | /// This can take a long time for large zip files.
217 | ///
218 | /// This won't work if the zip file uses a non-standard
219 | /// code page - neither IBM437 nor UTF-8.
220 | ///
221 | ///
222 | /// This method is not supported in the Reduced or Compact Framework
223 | /// versions of DotNetZip.
224 | ///
225 | ///
226 | ///
227 | /// Developers using COM can use the ComHelper.FixZipDirectory(String)
229 | /// method.
230 | ///
231 | ///
232 | ///
233 | ///
234 | /// The filename to of the zip file to fix.
235 | ///
236 | ///
237 | ///
238 | public static void FixZipDirectory(string zipFileName)
239 | {
240 | using (var zip = new ZipFile())
241 | {
242 | zip.FullScan = true;
243 | zip.Initialize(zipFileName);
244 | zip.Save(zipFileName);
245 | }
246 | }
247 |
248 |
249 |
250 | ///
251 | /// Verify the password on a zip file.
252 | ///
253 | ///
254 | ///
255 | ///
256 | /// Keep in mind that passwords in zipfiles are applied to
257 | /// zip entries, not to the entire zip file. So testing a
258 | /// zipfile for a particular password doesn't work in the
259 | /// general case. On the other hand, it's often the case
260 | /// that a single password will be used on all entries in a
261 | /// zip file. This method works for that case.
262 | ///
263 | ///
264 | /// There is no way to check a password without doing the
265 | /// decryption. So this code decrypts and extracts the given
266 | /// zipfile into
267 | ///
268 | ///
269 | ///
270 | /// The filename to of the zip file to fix.
271 | ///
272 | /// The password to check.
273 | ///
274 | /// a bool indicating whether the password matches.
275 | public static bool CheckZipPassword(string zipFileName, string password)
276 | {
277 | // workitem 13664
278 | bool success = false;
279 | try
280 | {
281 | using (ZipFile zip1 = ZipFile.Read(zipFileName))
282 | {
283 | foreach (var e in zip1)
284 | {
285 | if (!e.IsDirectory && e.UsesEncryption)
286 | {
287 | e.ExtractWithPassword(System.IO.Stream.Null, password);
288 | }
289 | }
290 | }
291 | success = true;
292 | }
293 | catch(Ionic.Zip.BadPasswordException) { }
294 | return success;
295 | }
296 |
297 |
298 | ///
299 | /// Provides a human-readable string with information about the ZipFile.
300 | ///
301 | ///
302 | ///
303 | ///
304 | /// The information string contains 10 lines or so, about each ZipEntry,
305 | /// describing whether encryption is in use, the compressed and uncompressed
306 | /// length of the entry, the offset of the entry, and so on. As a result the
307 | /// information string can be very long for zip files that contain many
308 | /// entries.
309 | ///
310 | ///
311 | /// This information is mostly useful for diagnostic purposes.
312 | ///
313 | ///
314 | public string Info
315 | {
316 | get
317 | {
318 | var builder = new System.Text.StringBuilder();
319 | builder.Append(string.Format(" ZipFile: {0}\n", this.Name));
320 | if (!string.IsNullOrEmpty(this._Comment))
321 | {
322 | builder.Append(string.Format(" Comment: {0}\n", this._Comment));
323 | }
324 | if (this._versionMadeBy != 0)
325 | {
326 | builder.Append(string.Format(" version made by: 0x{0:X4}\n", this._versionMadeBy));
327 | }
328 | if (this._versionNeededToExtract != 0)
329 | {
330 | builder.Append(string.Format("needed to extract: 0x{0:X4}\n", this._versionNeededToExtract));
331 | }
332 |
333 | builder.Append(string.Format(" uses ZIP64: {0}\n", this.InputUsesZip64));
334 |
335 | builder.Append(string.Format(" disk with CD: {0}\n", this._diskNumberWithCd));
336 | if (this._OffsetOfCentralDirectory == 0xFFFFFFFF)
337 | builder.Append(string.Format(" CD64 offset: 0x{0:X16}\n", this._OffsetOfCentralDirectory64));
338 | else
339 | builder.Append(string.Format(" CD offset: 0x{0:X8}\n", this._OffsetOfCentralDirectory));
340 | builder.Append("\n");
341 | foreach (ZipEntry entry in this._entries.Values)
342 | {
343 | builder.Append(entry.Info);
344 | }
345 | return builder.ToString();
346 | }
347 | }
348 |
349 |
350 | }
351 |
352 | }
--------------------------------------------------------------------------------
/MAutoUpdate/Zip DLL/ZipDirEntry.cs:
--------------------------------------------------------------------------------
1 | // ZipDirEntry.cs
2 | // ------------------------------------------------------------------
3 | //
4 | // Copyright (c) 2006-2011 Dino Chiesa .
5 | // All rights reserved.
6 | //
7 | // This code module is part of DotNetZip, a zipfile class library.
8 | //
9 | // ------------------------------------------------------------------
10 | //
11 | // This code is licensed under the Microsoft Public License.
12 | // See the file License.txt for the license details.
13 | // More info on: http://dotnetzip.codeplex.com
14 | //
15 | // ------------------------------------------------------------------
16 | //
17 | // last saved (in emacs):
18 | // Time-stamp: <2011-July-11 12:03:03>
19 | //
20 | // ------------------------------------------------------------------
21 | //
22 | // This module defines members of the ZipEntry class for reading the
23 | // Zip file central directory.
24 | //
25 | // Created: Tue, 27 Mar 2007 15:30
26 | //
27 | // ------------------------------------------------------------------
28 |
29 |
30 | using System;
31 | using System.Collections.Generic;
32 |
33 | namespace Ionic.Zip
34 | {
35 |
36 | partial class ZipEntry
37 | {
38 | ///
39 | /// True if the referenced entry is a directory.
40 | ///
41 | internal bool AttributesIndicateDirectory
42 | {
43 | get { return ((_InternalFileAttrs == 0) && ((_ExternalFileAttrs & 0x0010) == 0x0010)); }
44 | }
45 |
46 |
47 | internal void ResetDirEntry()
48 | {
49 | // __FileDataPosition is the position of the file data for an entry.
50 | // It is _RelativeOffsetOfLocalHeader + size of local header.
51 |
52 | // We cannot know the __FileDataPosition until we read the local
53 | // header.
54 |
55 | // The local header is not necessarily the same length as the record
56 | // in the central directory.
57 |
58 | // Set to -1, to indicate we need to read this later.
59 | this.__FileDataPosition = -1;
60 |
61 | // set _LengthOfHeader to 0, to indicate we need to read later.
62 | this._LengthOfHeader = 0;
63 |
64 | // reset the copy counter because we've got a good entry now
65 | CopyHelper.Reset();
66 | }
67 |
68 | ///
69 | /// Provides a human-readable string with information about the ZipEntry.
70 | ///
71 | public string Info
72 | {
73 | get
74 | {
75 | var builder = new System.Text.StringBuilder();
76 | builder
77 | .Append(string.Format(" ZipEntry: {0}\n", this.FileName))
78 | .Append(string.Format(" Version Made By: {0}\n", this._VersionMadeBy))
79 | .Append(string.Format(" Needed to extract: {0}\n", this.VersionNeeded));
80 |
81 | if (this._IsDirectory)
82 | builder.Append(" Entry type: directory\n");
83 | else
84 | {
85 | builder.Append(string.Format(" File type: {0}\n", this._IsText? "text":"binary"))
86 | .Append(string.Format(" Compression: {0}\n", this.CompressionMethod))
87 | .Append(string.Format(" Compressed: 0x{0:X}\n", this.CompressedSize))
88 | .Append(string.Format(" Uncompressed: 0x{0:X}\n", this.UncompressedSize))
89 | .Append(string.Format(" CRC32: 0x{0:X8}\n", this._Crc32));
90 | }
91 | builder.Append(string.Format(" Disk Number: {0}\n", this._diskNumber));
92 | if (this._RelativeOffsetOfLocalHeader > 0xFFFFFFFF)
93 | builder
94 | .Append(string.Format(" Relative Offset: 0x{0:X16}\n", this._RelativeOffsetOfLocalHeader));
95 | else
96 | builder
97 | .Append(string.Format(" Relative Offset: 0x{0:X8}\n", this._RelativeOffsetOfLocalHeader));
98 |
99 | builder
100 | .Append(string.Format(" Bit Field: 0x{0:X4}\n", this._BitField))
101 | .Append(string.Format(" Encrypted?: {0}\n", this._sourceIsEncrypted))
102 | .Append(string.Format(" Timeblob: 0x{0:X8}\n", this._TimeBlob))
103 | .Append(string.Format(" Time: {0}\n", Ionic.Zip.SharedUtilities.PackedToDateTime(this._TimeBlob)));
104 |
105 | builder.Append(string.Format(" Is Zip64?: {0}\n", this._InputUsesZip64));
106 | if (!string.IsNullOrEmpty(this._Comment))
107 | {
108 | builder.Append(string.Format(" Comment: {0}\n", this._Comment));
109 | }
110 | builder.Append("\n");
111 | return builder.ToString();
112 | }
113 | }
114 |
115 |
116 | // workitem 10330
117 | private class CopyHelper
118 | {
119 | private static System.Text.RegularExpressions.Regex re =
120 | new System.Text.RegularExpressions.Regex(" \\(copy (\\d+)\\)$");
121 |
122 | private static int callCount = 0;
123 |
124 | internal static void Reset()
125 | {
126 | callCount = 0;
127 | }
128 |
129 | internal static string AppendCopyToFileName(string f)
130 | {
131 | callCount++;
132 | if (callCount > 25)
133 | throw new OverflowException("overflow while creating filename");
134 |
135 | int n = 1;
136 | int r = f.LastIndexOf(".");
137 |
138 | if (r == -1)
139 | {
140 | // there is no extension
141 | System.Text.RegularExpressions.Match m = re.Match(f);
142 | if (m.Success)
143 | {
144 | n = Int32.Parse(m.Groups[1].Value) + 1;
145 | string copy = String.Format(" (copy {0})", n);
146 | f = f.Substring(0, m.Index) + copy;
147 | }
148 | else
149 | {
150 | string copy = String.Format(" (copy {0})", n);
151 | f = f + copy;
152 | }
153 | }
154 | else
155 | {
156 | //System.Console.WriteLine("HasExtension");
157 | System.Text.RegularExpressions.Match m = re.Match(f.Substring(0, r));
158 | if (m.Success)
159 | {
160 | n = Int32.Parse(m.Groups[1].Value) + 1;
161 | string copy = String.Format(" (copy {0})", n);
162 | f = f.Substring(0, m.Index) + copy + f.Substring(r);
163 | }
164 | else
165 | {
166 | string copy = String.Format(" (copy {0})", n);
167 | f = f.Substring(0, r) + copy + f.Substring(r);
168 | }
169 |
170 | //System.Console.WriteLine("returning f({0})", f);
171 | }
172 | return f;
173 | }
174 | }
175 |
176 |
177 |
178 | ///
179 | /// Reads one entry from the zip directory structure in the zip file.
180 | ///
181 | ///
182 | ///
183 | /// The zipfile for which a directory entry will be read. From this param, the
184 | /// method gets the ReadStream and the expected text encoding
185 | /// (ProvisionalAlternateEncoding) which is used if the entry is not marked
186 | /// UTF-8.
187 | ///
188 | ///
189 | ///
190 | /// a list of previously seen entry names; used to prevent duplicates.
191 | ///
192 | ///
193 | /// the entry read from the archive.
194 | internal static ZipEntry ReadDirEntry(ZipFile zf,
195 | Dictionary previouslySeen)
196 | {
197 | System.IO.Stream s = zf.ReadStream;
198 | System.Text.Encoding expectedEncoding = (zf.AlternateEncodingUsage == ZipOption.Always)
199 | ? zf.AlternateEncoding
200 | : ZipFile.DefaultEncoding;
201 |
202 | while (true)
203 | {
204 | int signature = Ionic.Zip.SharedUtilities.ReadSignature(s);
205 | // return null if this is not a local file header signature
206 | if (IsNotValidZipDirEntrySig(signature))
207 | {
208 | s.Seek(-4, System.IO.SeekOrigin.Current);
209 | // workitem 10178
210 | Ionic.Zip.SharedUtilities.Workaround_Ladybug318918(s);
211 |
212 | // Getting "not a ZipDirEntry signature" here is not always wrong or an
213 | // error. This can happen when walking through a zipfile. After the
214 | // last ZipDirEntry, we expect to read an
215 | // EndOfCentralDirectorySignature. When we get this is how we know
216 | // we've reached the end of the central directory.
217 | if (signature != ZipConstants.EndOfCentralDirectorySignature &&
218 | signature != ZipConstants.Zip64EndOfCentralDirectoryRecordSignature &&
219 | signature != ZipConstants.ZipEntrySignature // workitem 8299
220 | )
221 | {
222 | throw new BadReadException(String.Format(" Bad signature (0x{0:X8}) at position 0x{1:X8}", signature, s.Position));
223 | }
224 | return null;
225 | }
226 |
227 | int bytesRead = 42 + 4;
228 | byte[] block = new byte[42];
229 | int n = s.Read(block, 0, block.Length);
230 | if (n != block.Length) return null;
231 |
232 | int i = 0;
233 | ZipEntry zde = new ZipEntry();
234 | zde.AlternateEncoding = expectedEncoding;
235 | zde._Source = ZipEntrySource.ZipFile;
236 | zde._container = new ZipContainer(zf);
237 |
238 | unchecked
239 | {
240 | zde._VersionMadeBy = (short)(block[i++] + block[i++] * 256);
241 | zde._VersionNeeded = (short)(block[i++] + block[i++] * 256);
242 | zde._BitField = (short)(block[i++] + block[i++] * 256);
243 | zde._CompressionMethod = (Int16)(block[i++] + block[i++] * 256);
244 | zde._TimeBlob = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
245 | zde._LastModified = Ionic.Zip.SharedUtilities.PackedToDateTime(zde._TimeBlob);
246 | zde._timestamp |= ZipEntryTimestamp.DOS;
247 |
248 | zde._Crc32 = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
249 | zde._CompressedSize = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
250 | zde._UncompressedSize = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
251 | }
252 |
253 | // preserve
254 | zde._CompressionMethod_FromZipFile = zde._CompressionMethod;
255 |
256 | zde._filenameLength = (short)(block[i++] + block[i++] * 256);
257 | zde._extraFieldLength = (short)(block[i++] + block[i++] * 256);
258 | zde._commentLength = (short)(block[i++] + block[i++] * 256);
259 | zde._diskNumber = (UInt32)(block[i++] + block[i++] * 256);
260 |
261 | zde._InternalFileAttrs = (short)(block[i++] + block[i++] * 256);
262 | zde._ExternalFileAttrs = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
263 |
264 | zde._RelativeOffsetOfLocalHeader = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
265 |
266 | // workitem 7801
267 | zde.IsText = ((zde._InternalFileAttrs & 0x01) == 0x01);
268 |
269 | block = new byte[zde._filenameLength];
270 | n = s.Read(block, 0, block.Length);
271 | bytesRead += n;
272 | if ((zde._BitField & 0x0800) == 0x0800)
273 | {
274 | // UTF-8 is in use
275 | zde._FileNameInArchive = Ionic.Zip.SharedUtilities.Utf8StringFromBuffer(block);
276 | }
277 | else
278 | {
279 | zde._FileNameInArchive = Ionic.Zip.SharedUtilities.StringFromBuffer(block, expectedEncoding);
280 | }
281 |
282 | // workitem 10330
283 | // insure unique entry names
284 | while (!zf.IgnoreDuplicateFiles && previouslySeen.ContainsKey(zde._FileNameInArchive))
285 | {
286 | zde._FileNameInArchive = CopyHelper.AppendCopyToFileName(zde._FileNameInArchive);
287 | zde._metadataChanged = true;
288 | }
289 |
290 | if (zde.AttributesIndicateDirectory)
291 | zde.MarkAsDirectory(); // may append a slash to filename if nec.
292 | // workitem 6898
293 | else if (zde._FileNameInArchive.EndsWith("/")) zde.MarkAsDirectory();
294 |
295 | zde._CompressedFileDataSize = zde._CompressedSize;
296 | if ((zde._BitField & 0x01) == 0x01)
297 | {
298 | // this may change after processing the Extra field
299 | zde._Encryption_FromZipFile = zde._Encryption =
300 | EncryptionAlgorithm.PkzipWeak;
301 | zde._sourceIsEncrypted = true;
302 | }
303 |
304 | if (zde._extraFieldLength > 0)
305 | {
306 | zde._InputUsesZip64 = (zde._CompressedSize == 0xFFFFFFFF ||
307 | zde._UncompressedSize == 0xFFFFFFFF ||
308 | zde._RelativeOffsetOfLocalHeader == 0xFFFFFFFF);
309 |
310 | // Console.WriteLine(" Input uses Z64?: {0}", zde._InputUsesZip64);
311 |
312 | bytesRead += zde.ProcessExtraField(s, zde._extraFieldLength);
313 | zde._CompressedFileDataSize = zde._CompressedSize;
314 | }
315 |
316 | // we've processed the extra field, so we know the encryption method is set now.
317 | if (zde._Encryption == EncryptionAlgorithm.PkzipWeak)
318 | {
319 | // the "encryption header" of 12 bytes precedes the file data
320 | zde._CompressedFileDataSize -= 12;
321 | }
322 | #if AESCRYPTO
323 | else if (zde.Encryption == EncryptionAlgorithm.WinZipAes128 ||
324 | zde.Encryption == EncryptionAlgorithm.WinZipAes256)
325 | {
326 | zde._CompressedFileDataSize = zde.CompressedSize -
327 | (ZipEntry.GetLengthOfCryptoHeaderBytes(zde.Encryption) + 10);
328 | zde._LengthOfTrailer = 10;
329 | }
330 | #endif
331 |
332 | // tally the trailing descriptor
333 | if ((zde._BitField & 0x0008) == 0x0008)
334 | {
335 | // sig, CRC, Comp and Uncomp sizes
336 | if (zde._InputUsesZip64)
337 | zde._LengthOfTrailer += 24;
338 | else
339 | zde._LengthOfTrailer += 16;
340 | }
341 |
342 | // workitem 12744
343 | zde.AlternateEncoding = ((zde._BitField & 0x0800) == 0x0800)
344 | ? System.Text.Encoding.UTF8
345 | :expectedEncoding;
346 |
347 | zde.AlternateEncodingUsage = ZipOption.Always;
348 |
349 | if (zde._commentLength > 0)
350 | {
351 | block = new byte[zde._commentLength];
352 | n = s.Read(block, 0, block.Length);
353 | bytesRead += n;
354 | if ((zde._BitField & 0x0800) == 0x0800)
355 | {
356 | // UTF-8 is in use
357 | zde._Comment = Ionic.Zip.SharedUtilities.Utf8StringFromBuffer(block);
358 | }
359 | else
360 | {
361 | zde._Comment = Ionic.Zip.SharedUtilities.StringFromBuffer(block, expectedEncoding);
362 | }
363 | }
364 | //zde._LengthOfDirEntry = bytesRead;
365 | if (zf.IgnoreDuplicateFiles && previouslySeen.ContainsKey(zde._FileNameInArchive))
366 | {
367 | continue;
368 | }
369 | return zde;
370 | }
371 | }
372 |
373 |
374 | ///
375 | /// Returns true if the passed-in value is a valid signature for a ZipDirEntry.
376 | ///
377 | /// the candidate 4-byte signature value.
378 | /// true, if the signature is valid according to the PKWare spec.
379 | internal static bool IsNotValidZipDirEntrySig(int signature)
380 | {
381 | return (signature != ZipConstants.ZipDirEntrySignature);
382 | }
383 |
384 |
385 | private Int16 _VersionMadeBy;
386 | private Int16 _InternalFileAttrs;
387 | private Int32 _ExternalFileAttrs;
388 |
389 | //private Int32 _LengthOfDirEntry;
390 | private Int16 _filenameLength;
391 | private Int16 _extraFieldLength;
392 | private Int16 _commentLength;
393 | }
394 |
395 |
396 | }
397 |
--------------------------------------------------------------------------------