Example #1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var files = System.IO.Directory.GetFiles(txtDir.Text, "随身袋.exe");
                if (files.Length == 1)
                {
                    System.Diagnostics.FileVersionInfo fv = System.Diagnostics.FileVersionInfo.GetVersionInfo(System.IO.Path.GetFullPath(files[0]));
                    var asmTitle = fv.ProductName;
                    var asmVer = fv.ProductVersion;
                    txtAppName.Text = asmTitle;
                    txtCVer.Text = asmVer;
                    System.IO.FileInfo file = new System.IO.FileInfo(System.IO.Path.GetFullPath(files[0]));
                    txtUpdateTime.Text = file.LastWriteTime.ToShortDateString();
                }

                txtDes.Text = System.IO.File.ReadAllText((@"..\..\..\随身袋\bin\Release\CarryBag\使用说明.txt"));

                System.IO.File.Delete("update.zip");

                ICCEmbedded.SharpZipLib.Zip.FastZipEvents evt = new ICCEmbedded.SharpZipLib.Zip.FastZipEvents();
                ICCEmbedded.SharpZipLib.Zip.FastZip fz = new ICCEmbedded.SharpZipLib.Zip.FastZip(evt);
                fz.CreateZip("update.zip", txtDir.Text, true, "");

                System.IO.FileInfo file2 = new System.IO.FileInfo(System.IO.Path.GetFullPath("update.zip"));
                txtPackageSize.Text = file2.Length.ToString();

                UpdateInfo uinfo = new UpdateInfo();
                uinfo.AppName = txtAppName.Text;
                uinfo.AppVersion = txtCVer.Text;
                uinfo.Desc = txtDes.Text;
                uinfo.RequiredMinVersion = txtMinVer.Text;
                uinfo.PackageName = txtPackageName.Text;
                uinfo.PackageSize = txtPackageSize.Text;
                uinfo.UpdateTime = txtUpdateTime.Text;

                EasyFramework.Serialize.XMLHelper.Serialize("update.xml", uinfo);
            }
            catch { }
        }
		/// <summary>
		/// 解开安装包
		/// </summary>
		void ExtractPackage(RunworkEventArgs rt)
		{
			Trace.TraceInformation("开始解压缩升级包");
			rt.PostEvent(() => OnPackageExtractionBegin(new PackageEventArgs(null)));

			var fze = new ICCEmbedded.SharpZipLib.Zip.FastZipEvents();
			fze.ProcessFile += (s, e) => rt.ReportProgress(0, 0, string.Format(SR.Updater_ExtractingFile, e.Name));
			var fz = new ICCEmbedded.SharpZipLib.Zip.FastZip(fze);
			if (!string.IsNullOrEmpty(Context.UpdateInfo.PackagePassword))
			{
				fz.Password = Context.UpdateInfo.PackagePassword;
			}

			foreach (var pkg in PackagesToUpdate)
			{
				Trace.TraceInformation("正在解压缩 " + pkg.PackageName);
				rt.PostEvent(() => OnPackageExtractionBegin(new PackageEventArgs(pkg)));

				fz.ExtractZip(pkg.LocalSavePath, Context.UpdateNewFilePath, null);

				rt.PostEvent(() => OnPackageExtractionEnd(new PackageEventArgs(pkg)));
				Trace.TraceInformation("完成解压缩 " + pkg.PackageName);
			}

			rt.PostEvent(() => OnPackageExtractionEnd(new PackageEventArgs(null)));
			Trace.TraceInformation("完成解压缩升级包");
		}
Example #3
0
 private static void UnZipFile(string zipFilePath, string targetDir)
 {
     ICCEmbedded.SharpZipLib.Zip.FastZipEvents evt = new ICCEmbedded.SharpZipLib.Zip.FastZipEvents();
     ICCEmbedded.SharpZipLib.Zip.FastZip fz = new ICCEmbedded.SharpZipLib.Zip.FastZip(evt);
     fz.ExtractZip(zipFilePath, targetDir, "");
 }
Example #4
0
 /// <summary>
 /// 解开安装包
 /// </summary>
 void ExtractPackage(RunworkEventArgs e)
 {
     e.ReportProgress(0, 0, Infrastructure.Crosscutting.Updater.SR.Updater_ExtractPackage);
     ICCEmbedded.SharpZipLib.Zip.FastZipEvents evt = new ICCEmbedded.SharpZipLib.Zip.FastZipEvents();
     evt.ProcessFile += (s, f) =>
     {
         e.ReportProgress(0, 0, "正在解压缩 " + System.IO.Path.GetFileName(f.Name));
     };
     ICCEmbedded.SharpZipLib.Zip.FastZip fz = new ICCEmbedded.SharpZipLib.Zip.FastZip(evt);
     if (!string.IsNullOrEmpty(UpdateInfo.PackagePassword)) fz.Password = UpdateInfo.PackagePassword;
     fz.ExtractZip(UpdatePackageFilePath, UpdateSourceDirectory, "");
 }