public static CreateFromDirectory ( string sourceDirectoryName, string destinationArchiveFileName ) : void | ||
sourceDirectoryName | string | The path to the directory on the file system to be archived. |
destinationArchiveFileName | string | The name of the archive to be created. |
return | void |
private void generateWindowsPortable(Console console) { console.WriteLine("=================================="); console.WriteLine("Generating Windows Portable Deploy..."); var zipPath = textDeployFolder.Text + "\\" + textNamespace.Text + "." + textVersion.Text; if (chkDemo.Checked) { zipPath += "." + textDemoTag.Text; } zipPath += ".Windows.Portable.zip"; var tempPath = textDeployFolder.Text + "\\" + textTitle.Text; var files = Directory.GetFiles(textReleaseFolder.Text, "*.*", SearchOption.AllDirectories); foreach (var file in files) { var fileRelative = file; fileRelative = fileRelative.Replace(textReleaseFolder.Text, ""); var fileDir = new FileInfo(tempPath + fileRelative); fileDir.Directory.Create(); File.Copy(file, tempPath + fileRelative, true); console.WriteLine("Copy To Temp: " + file); } console.WriteLine("Creating Zip File..." + zipPath); if (File.Exists(zipPath)) { File.Delete(zipPath); } ZipFile.CreateFromDirectory(tempPath, zipPath, CompressionLevel.Optimal, true); console.Write("Deleting Temp Folder..."); Directory.Delete(tempPath, true); console.WriteLine("OK"); }
public string DownloadZip(string filesToDownload, string archName, string productId, string pathToFilesFolder) { List <string> files = filesToDownload.Split(';').ToList(); var curDate = DateTime.Now.ToShortDateString().Replace("-", "").Replace(":", "").Replace(".", "").Replace("\\", "").Replace("/", ""); var archiveOutFolder = AppDomain.CurrentDomain.BaseDirectory + ($"\\tempout\\{curDate}\\{productId}\\"); var tempFolder = AppDomain.CurrentDomain.BaseDirectory + "\\temp\\"; if (!Directory.Exists(archiveOutFolder)) { Directory.CreateDirectory(archiveOutFolder); } var archive = string.Concat(archiveOutFolder, archName); ClearTempDirectories(curDate, tempFolder); files.ForEach(f => CopyFile(pathToFilesFolder, f, tempFolder)); if (File.Exists(archive)) { File.Delete(archive); } ZipFileCustom.CreateFromDirectory(tempFolder, archive, CompressionLevel.Optimal, false); return($"../tempout/{curDate}/{productId}/{archName}"); }