Exemple #1
0
        private void DownloadPackages(string source, string tempDownloadPath, string fileName)
        {
            var fullPackagePath = Path.Combine(tempDownloadPath, fileName);

            Directory.CreateDirectory(tempDownloadPath);
            string sourceFilePath = Path.Combine(source, fileName);

            using (WebClient) {
                WebClient.DownloadFile(new Uri(sourceFilePath), fullPackagePath);
            }
            CompressionUtilities.UnzipDirectory(fullPackagePath, true);
        }
Exemple #2
0
 public void CompressionProject(string sourcePath, string destinationDirectory, string packageName)
 {
     try {
         var startDate          = DateTime.Now;
         var packageContentPath = GetPackageContentPath(sourcePath);
         var tempPackagePath    = CreateTempPath();
         CopyProjectFiles(packageContentPath, tempPackagePath);
         var files       = Directory.GetFiles(tempPackagePath, "*.*", SearchOption.AllDirectories);
         var archivePath = Path.Combine(destinationDirectory, packageName);
         using (Stream stream = File.Open(archivePath + ArchiveFormat, FileMode.Create, FileAccess.Write,
                                          FileShare.None)) {
             using (var zipStream = new GZipStream(stream, CompressionMode.Compress)) {
                 foreach (var filePath in files)
                 {
                     CompressionUtilities.ZipFile(filePath, tempPackagePath.Length, zipStream);
                 }
             }
         }
         Directory.Delete(tempPackagePath, true);
         _logger.LogInfo($"{packageName} is compression ({(DateTime.Now - startDate)})");
     } catch (Exception ex) {
         _logger.LogError(ex.Message);
     }
 }