示例#1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (!Check())
            {
                return;
            }
            var options = new ZipFileUpdaterOptions()
            {
                SourceZipFileName = this.cbSrcFilePath.Text,
                OutputPath        = this.cbDestDirPath.Text,
                BackupOutputPath  = this.cbBackupPath.Text,
                BackupName        = this.cbBackupFileName.Text,
                OnProcessing      = UpdateLog,
                OnEnd             = OnEnd
            };
            //if (string.IsNullOrEmpty( options.BackupOutputPath))
            //{
            //    options.BackupOutputPath = Path.Combine(System.IO.Directory.GetCurrentDirectory(), "backup");
            //}

            ZipFileUpdater zipFileUpdater = new ZipFileUpdater(options);

            zipFileUpdater.StartAsync();
            SaveLog();
            this.btnOpenDir.Enabled     = false;
            this.btnOpenSrcFile.Enabled = false;
            this.btnStart.Enabled       = false;
        }
示例#2
0
        public ZipFileUpdater(ZipFileUpdaterOptions options)
        {
            _options = options;
            if (!File.Exists(options.SourceZipFileName))
            {
                throw new FileNotFoundException(options.SourceZipFileName);
            }

            if (!Directory.Exists(_options.BackupOutputPath))
            {
                Directory.CreateDirectory(_options.BackupOutputPath);
            }
            string dateString = DateTime.Now.ToString("yyyyMMddHHmmssff");
            string fileName   = $"{_options.BackupName??"backup"}-{dateString}.zip";

            _tempOutputPath       = $"temp-{dateString}";
            _tempOutputPath       = Path.Combine(_options.BackupOutputPath, _tempOutputPath);
            _tempOutputBackupFile = Path.Combine(_options.BackupOutputPath, fileName);
            //_zipBackUpFile =ZipFile.Create(File.Create(Path.Combine(_options.BackupOutputPath, fileName)));
            _zipFile = new ZipFile(File.Open(options.SourceZipFileName, FileMode.Open));
        }