private void BindData() { List <FileCollision> fileCollisions = new List <FileCollision>(); Dictionary <string, UpdateItem> filesInPublication = new Dictionary <string, UpdateItem>(); AutoUpdateManager.TryGetPublicationFiles(PublicationID, out filesInPublication, out fileCollisions); if (fileCollisions.Count > 0) { pFileCollisions.Visible = true; pNoFileCollisions.Visible = false; pPublishMergedPublications.Visible = DeployPublication; pDownloadMergedPublications.Visible = DeployPublication == false; gvCollisions.DataSource = fileCollisions; gvCollisions.DataBind(); } else { pNoFileCollisions.Visible = false; pFileCollisions.Visible = false; if (DeployPublication == true) { btnDeployPublication_Click(this, EventArgs.Empty); } else { pNoFileCollisions.Visible = true; } } PublicationDownloaderUrl = "PublicationDownloaderIframe.aspx?target=" + PublicationID; }
protected void Page_Load(object sender, EventArgs e) { List <FileCollision> fileCollisions = new List <FileCollision>(); Dictionary <string, UpdateItem> filesInPublication = new Dictionary <string, UpdateItem>(); AutoUpdateManager.TryGetPublicationFiles(PublicationID, out filesInPublication, out fileCollisions); string publicationName = AutoUpdateManager.GetPublicationName(PublicationID); string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); Directory.CreateDirectory(tempPath); foreach (string filename in filesInPublication.Keys) { string targetFile = Path.Combine(tempPath, filename); if (Directory.Exists(Path.GetDirectoryName(targetFile)) == false) { Directory.CreateDirectory(Path.GetDirectoryName(targetFile)); } File.Copy(filesInPublication[filename].FileInfo.FullName, targetFile, true); } ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip(); string zipFilename = Path.GetTempFileName(); fastZip.CreateZip(zipFilename, tempPath, true, String.Empty); byte[] outputBytes = File.ReadAllBytes(zipFilename); Directory.Delete(tempPath, true); File.Delete(zipFilename); Response.ContentType = "application/zip"; Response.AddHeader("Content-Disposition", "attachment; filename=" + publicationName + ".zip"); Response.AddHeader("ContentLength", outputBytes.Length.ToString()); Response.BinaryWrite(outputBytes); }