示例#1
0
        public void Backup(string filePath, string srcFolder, byte[] archHeader)
        {
            Initializing?.Invoke();

            FilesBag bag = CreateBag(srcFolder);

            FileStream fsDest = null;

            try
            {
                fsDest = File.Create(filePath);
                var writer = new RawDataWriter(fsDest, Encoding.UTF8);
                writer.Write(Signature);
                writer.Write(DateTime.Now);
                writer.Write(archHeader.Length);
                writer.Write(archHeader);

                Compressing?.Invoke();
                bag.Compress(fsDest);

                Done?.Invoke();
            }
            catch
            {
                if (fsDest != null)
                {
                    fsDest.Dispose();
                    File.Delete(filePath);
                }

                throw;
            }
        }
示例#2
0
 private void OnCompressing(ProgressEventArgs e)
 {
     Compressing?.Invoke(this, e);
 }