Esempio n. 1
0
 /// <summary>
 /// Implements <see cref="IFileCompressor.CompressFile(string, string)"/> using the .Net4.5 specific <see cref="ZipArchive"/>
 /// </summary>
 public void CompressFile(string fileName, string archiveFileName)
 {
     using (FileStream originalFileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         using (FileStream compressedFileStream = File.Create(archiveFileName))
         {
             using (GZipStream compressionStream = new GZipStream(compressedFileStream, CompressionMode.Compress))
             {
                 originalFileStream.CopyTo(compressionStream);
             }
         }
     }
     S3Uploader.UploadCompressedFile(archiveFileName);
 }
 /// <summary>
 /// Implements <see cref="IFileCompressor.CompressFile(string, string)"/> using the .Net4.5 specific <see cref="ZipArchive"/>
 /// </summary>
 public void CompressFile(string fileName, string archiveFileName)
 {
     using (FileStream fileToBeZippedAsStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
     {
         using (FileStream compressedFileStream = File.Create(archiveFileName))
         {
             try
             {
                 BZip2.Compress(fileToBeZippedAsStream, compressedFileStream, true, 5);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
             }
         }
     }
     S3Uploader.UploadCompressedFile(archiveFileName);
 }