[
  {
    "Id": "433274",
    "ThreadId": "209944",
    "Html": "<p>Hi Cheso,</p>\r\n<p>The following code I've created from examples around the DotNetZip disscussion forums is working under a normal app environment for us:</p>\r\n<p>&nbsp;&nbsp;&nbsp; protected void makeZip(object sender, EventArgs e)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string archiveTitle = (poYearDropDownList.SelectedItem.Value + poProgramDropDownList.SelectedItem.Value).ToString();</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string fileName = String.Empty;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string ZipFileName = Server.MapPath(Path.Combine(&quot;zipFiles&quot;, Guid.NewGuid().ToString() + &quot;.zip&quot;));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string pathToFile = (&quot;z:\\\\this\\\\is\\\\not\\\\theReal\\\\filePath\\\\&quot;);&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (ZipFile POzip = new ZipFile())<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (GridViewRow PO in GridView1.Rows)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fileName = (PO.FindControl(&quot;POLabel&quot;) as Label).Text;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; POzip.AddFile(pathToFile + fileName, &quot;&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; POzip.Save(ZipFileName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Clear();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.BufferOutput = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.ContentType = &quot;application/zip&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string archiveName = String.Format(archiveTitle + &quot;-{0}.zip&quot;, DateTime.Now.ToString(&quot;yyyy-MMM-dd-HHmmss&quot;));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.AppendHeader(&quot;Content-Disposition&quot;, &quot;attachment; filename=&quot; + archiveName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.WriteFile(ZipFileName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Flush();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Close();</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // delete the temp file <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (File.Exists(&quot;zipFiles/&quot; + ZipFileName))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; File.Delete(&quot;zipFiles/&quot; + ZipFileName);</p>\r\n<p>However - for reasons that I'll not go into here - on occasion there will be a &quot;file not found&quot; - in that - the file name listed in the gridView will not actually exsist in the directory where all the files can be found.</p>\r\n<p>Is there a way (in C#) that you know of to &quot;skip the file&quot; then move on to the next file in my foreach loop?&nbsp; I'm assuming an If statement is needed, but am drawing a blank on where to start.</p>\r\n<p>Thanks for such a great zip library!</p>\r\n<p>-Doug</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-04-20T10:56:32.347-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "433277",
    "ThreadId": "209944",
    "Html": "<p>Well, duh, I just figured this out - and added:</p>\r\n<p>if(File.Exists(pathToFile + fileName))</p>\r\n<p>&nbsp;{</p>\r\n<p>&nbsp;POzip.AddFile(pathToFile + fileName, &quot;&quot;);</p>\r\n<p>}</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-04-20T11:07:45.287-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]