[
  {
    "Id": "193680",
    "ThreadId": "57316",
    "Html": "<p>Hello,</p>\r\n<p>I am trying to use DotNetZip with the TreeView control using checkboxes. I can populate the treeview with files from the file system but I cant grasp the concept of putting them in a zip file if checked.</p>\r\n<p>The following is my code for the treeview:</p>\r\n<p>&nbsp;void PopulateNode(Object source, TreeNodeEventArgs e)<br>{<br>&nbsp;TreeNode node = e.Node;<br>&nbsp;if (node.Value == &quot;Files&quot;)<br>&nbsp;{<br>&nbsp;&nbsp;node.Value = &quot;~/&quot;;<br>&nbsp;}<br>&nbsp;String rootDirectory = Request.MapPath(&quot;~/&quot;, Request.ApplicationPath, false);<br>&nbsp;String fullPath = Request.MapPath(node.Value, Request.ApplicationPath, false);</p>\r\n<p>&nbsp;if (fullPath.StartsWith(rootDirectory) == false)<br>&nbsp;{<br>&nbsp;&nbsp;// Mitigate against spoofed callback arguments<br>&nbsp;&nbsp;// Requested directory is not under root directory<br>&nbsp;&nbsp;return;<br>&nbsp;}</p>\r\n<p>&nbsp;String[] dirs = Directory.GetDirectories(fullPath);</p>\r\n<p>&nbsp;// Enumerate directories<br>&nbsp;foreach (String dir in dirs)<br>&nbsp;{<br>&nbsp;&nbsp;String virtualDir = node.Value.TrimEnd(_slashArray) + &quot;/&quot; + Path.GetFileName(dir);</p>\r\n<p>&nbsp;&nbsp;TreeNode newNode = new TreeNode(Path.GetFileName(dir), virtualDir);<br>&nbsp;&nbsp;if (Directory.GetFiles(dir).Length &gt; 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; || Directory.GetDirectories(dir).Length &gt; 0)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;newNode.PopulateOnDemand = true;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;node.ChildNodes.Add(newNode);<br>&nbsp;}</p>\r\n<p>&nbsp;// Enumerate files<br>&nbsp;String[] files = Directory.GetFiles(fullPath);<br>&nbsp;foreach (String file in files)<br>&nbsp;{<br>&nbsp;&nbsp;TreeNode newNode = new TreeNode(Path.GetFileName(file), Path.GetFileName(file));<br>&nbsp;&nbsp;node.ChildNodes.Add(newNode);<br>&nbsp;}<br>}</p>\r\n<p>&nbsp;Help would be much appreciated.</p>\r\n<p>Thanks</p>",
    "PostedDate": "2009-05-24T07:35:49.4-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "193729",
    "ThreadId": "57316",
    "Html": "<p>??? Is it ASP.NET or Windows Forms, or something else?</p>\r\n<p>Regardless, it seems like you want to set up a button, with an OnClick event handler. Within the OnClick method, instantiate a ZipFile object.&nbsp; Then, walk the nodes of the tree, going through each one.&nbsp; For each node in the tree, if the checkbox is checked, then add the filename for that node to the ZipFile with zip.AddFile().</p>\r\n<p>At the end of looping through all the nodes. call ZipFile.Save().</p>\r\n<p>Is that helpful?</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-05-24T14:35:53.43-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "193762",
    "ThreadId": "57316",
    "Html": "\r\n\r\n<div class=Section1>\r\n\r\n<p class=MsoNormal><span class=SpellE><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">Cheeso</span></span><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">,</span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\"> </span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">Thanks for the reply. I appreciate\r\nyour help. Of course I am new to this I am learning .NET using C#. <span style=\"\"> </span>I am not too familiar with the <span class=SpellE>Treeview</span> and its properties. So here is my attempt:</span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\"> </span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New';color:blue\">using</span><span style=\"font-size:10.0pt;font-family:'Courier New'\"> (<span style=\"color:#2B91AF\">ZipFile</span> zip = <span style=\"color:blue\">new</span> <span style=\"color:#2B91AF\">ZipFile</span>(Response.OutputStream))</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">    </span>{</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">        </span><span style=\"color:blue\">foreach</span> (<span style=\"color:#2B91AF\">TreeNode</span>\r\nnode <span style=\"color:blue\">in</span> MyTree.CheckedNodes)</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">        </span>{</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">            </span><span style=\"color:blue\">if</span> (MyTree.SelectedNode != <span style=\"color:blue\">null</span>)</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">            </span>{</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">                </span><span style=\"color:blue\">if</span> (<span style=\"color:#2B91AF\">Directory</span>.Exists(MyTree.SelectedNode.Checked)\r\n== <span style=\"color:blue\">true</span>)</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">                    </span>{</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">                       \r\n</span>zip.AddFile(MyTree.SelectedNode.Value);</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">                    </span>}</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">            </span>}</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">        </span>}</span></p>\r\n\r\n<p class=MsoNormal style=\"text-autospace:none\"><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">        </span>zip.Save();</span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:10.0pt;font-family:'Courier New'\"><span style=\"\">    </span>}</span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:10.0pt;font-family:'Courier New'\"> </span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:10.0pt;font-family:'Courier New'\">Now I am trying to\r\nkeep the directory structure as is when zipping as there will be multiple\r\nfolders and multiple files in them. </span><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\"></span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\"> </span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">I don’t think I am doing\r\nthis right would you mind helping me out. </span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\"> </span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">Thanks again,</span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\"> </span></p>\r\n\r\n<p class=MsoNormal><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\"> </span></p>\r\n\r\n<div>\r\n\r\n<div style=\"border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in\">\r\n\r\n<p class=MsoNormal><b><span style=\"font-size:10.0pt;font-family:'Tahoma','sans-serif'\">From:</span></b><span style=\"font-size:10.0pt;font-family:'Tahoma','sans-serif'\"> Cheeso [mailto:notifications@codeplex.com] <br>\r\n<b>Sent:</b> Sunday, May 24, 2009 2:36 PM<br>\r\n<b>To:</b> kjohnson@kristopherstudios.com<br>\r\n<b>Subject:</b> Re: TreeView w/ Checkboxes [DotNetZip:57316]</span></p>\r\n\r\n</div>\r\n\r\n</div>\r\n\r\n<p class=MsoNormal> </p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif'\">From:\r\nCheeso</span></p>\r\n\r\n<div style=\"margin-bottom:24.0pt\" id=ThreadNotificationPostBody>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif'\">??? Is it\r\nASP.NET or Windows Forms, or something else?</span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif'\">Regardless,\r\nit seems like you want to set up a button, with an OnClick event handler.\r\nWithin the OnClick method, instantiate a ZipFile object.  Then, walk the\r\nnodes of the tree, going through each one.  For each node in the tree, if\r\nthe checkbox is checked, then add the filename for that node to the ZipFile\r\nwith zip.AddFile().</span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif'\">At the end\r\nof looping through all the nodes. call ZipFile.Save().</span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif'\">Is that\r\nhelpful?</span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif'\"> </span></p>\r\n\r\n</div>\r\n\r\n<div style=\"border:none;border-top:solid #CCCCCC 1.0pt;padding:0in 0in 0in 0in\" id=ThreadNotificationFooter>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif';color:gray\">Read\r\nthe <a href=\"http://dotnetzip.codeplex.com/Thread/View.aspx?ThreadId=57316&ANCHOR#Post193729\">full\r\ndiscussion online</a>.</span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif';color:gray\">To\r\nadd a post to this discussion, reply to this email (<a href=\"mailto:DotNetZip@discussions.codeplex.com?subject=[DotNetZip:57316]\">DotNetZip@discussions.codeplex.com</a>)</span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif';color:gray\">To\r\nstart a new discussion for this project, email <a href=\"mailto:DotNetZip@discussions.codeplex.com\">DotNetZip@discussions.codeplex.com</a></span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif';color:gray\">You\r\nare receiving this email because you subscribed to this discussion on CodePlex.\r\nYou can <a href=\"http://www.codeplex.com/site/discussions/thread/unsubscribe/57316\">unsubscribe</a>\r\non codePlex.com.</span></p>\r\n\r\n<p><span style=\"font-size:9.0pt;font-family:'Verdana','sans-serif';color:gray\">Please\r\nnote: Images and attachments will be removed from emails. Any posts to this\r\ndiscussion will also be available online at codeplex.com</span></p>\r\n\r\n</div>\r\n\r\n</div>\r\n\r\n",
    "PostedDate": "2009-05-24T18:28:25.67-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "193816",
    "ThreadId": "57316",
    "Html": "<p>What you are doing seems ok to me.</p>\r\n<p>You asked for help. But what's the problem you're having?</p>",
    "PostedDate": "2009-05-25T01:00:37.277-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]