[
  {
    "Id": "263541",
    "ThreadId": "77080",
    "Html": "<p>Hi All,</p>\r\n<p>&nbsp;&nbsp; I am trying to use the&nbsp;<span style=\"font-size:x-small\">zip.AddFile&nbsp;</span><span style=\"font-size:x-small\">(HttpContext.Current.Server.MapPath(<a href=\"http://sharepointsite/abcd.doc).\">http://sharepointsite/abcd.doc).</a>,&quot;&quot;) method to add the files to the zip folder for zipping but it gives the error </span></p>\r\n<p><span style=\"font-size:x-small\">&quot;<a href=\"http://sharepointsite/abcd.doc.\">http://sharepointsite/abcd.doc</a>&nbsp;is not a valid virtual path.&quot; . Is there any other way to add a file to the zip folder by passing the file's Url in the zip.AddFile() method ? It is very urgent.</span></p>\r\n<p>&nbsp;</p>\r\n<p>Thanks</p>\r\n<p>Elizabeth</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-04T01:35:27.797-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "263548",
    "ThreadId": "77080",
    "Html": "<p>Hi,</p>\r\n<p>I forgot to mention that the files&nbsp;on which the&nbsp;zipping operation&nbsp;is to be performed will&nbsp;reside in a sharepoint document library that can be accessed from the corresponding sharepoint site.</p>",
    "PostedDate": "2009-12-04T02:13:02.59-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "263916",
    "ThreadId": "77080",
    "Html": "<p>Servver.MapPath requires a filesystem path, not a URL.&nbsp;</p>\r\n<p>(This has nothing to do with DotNetZip).</p>\r\n<blockquote style=\"border:1 dotted black\">\r\n<p>&gt; Is there any other way to add a file to the zip folder by passing the file's Url in the zip.AddFile() method ?</p>\r\n</blockquote>\r\n<p>Yes, you can create a zip entry from a URL, by first opening a stream on the URL.&nbsp; There's a handy class in the .NET BCL for this:&nbsp; System.Net.WebClient.&nbsp;&nbsp;Call the <a href=\"http://msdn.microsoft.com/en-us/library/781fwaz8.aspx\">OpenRead() method</a> on that class, which gives you a stream.&nbsp; Then pass that stream to <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/7bc513f6-c21c-6a02-3964-f2a571308a33.htm\">the zipFile.AddEntry() method that accepts a stream</a>.</p>\r\n<div>it looks like this:</div>\r\n<div>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Green\">// Create a new WebClient instance.</span>\r\nSystem.Net.WebClient wc = <span style=\"color:Blue\">new</span> System.Net.WebClient();\r\n<span style=\"color:Green\">// get the stream for a particular URL</span>\r\nStream s = wc.OpenRead(<span style=\"color:#A31515\">&quot;http://server/foo&quot;</span>); \r\n<span style=\"color:Green\">// add an entry into the zipfile using that stream as input</span>\r\nzip.AddEntry(<span style=\"color:#A31515\">&quot;MyEntryName.txt&quot;</span>, s);\r\n<span style=\"color:Green\">// close the stream</span>\r\ns.Close(); \r\n\r\n</pre>\r\n</div>\r\n&lt;!----&gt;</div>",
    "PostedDate": "2009-12-05T05:13:55.977-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "264315",
    "ThreadId": "77080",
    "Html": "<div>\r\n<p><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">Thanks a lot </span><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">you that would simplify my code drastically</span></p>\r\n<p><span style=\"font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D\">&nbsp;</span></p>\r\n</div>",
    "PostedDate": "2009-12-06T21:01:46.087-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "264417",
    "ThreadId": "77080",
    "Html": "<p>Hi,</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp; I followed the above method using OpenRead() and&nbsp; tried using DownloadData() method for stream and byte[] respectively.</p>\r\n<p>It works fine as long as the document getting zipped is a .txt document but for the other types of documents, its zips the document</p>\r\n<p>but when I try to open the document it gives the message that the document format is not supported and opens the document with data in a wrong format.</p>\r\n<p>Any ideas ?</p>\r\n<p>&nbsp;</p>\r\n<p>Ps: the OpenRead() and DownloadData() are both passed to a zip.AddEntry() method .</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks</p>\r\n<p>Elizabeth</p>",
    "PostedDate": "2009-12-07T04:02:23.107-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "264458",
    "ThreadId": "77080",
    "Html": "<p>Hi Elizabeth,</p>\r\n<p>If I were doing this I would ...:</p>\r\n<ul>\r\n<li>download the URL directly, save it, and try to open it.&nbsp; Does it work?</li>\r\n<li>do the zip.AddEntry() thing, and then save.&nbsp; Then, open the zip.&nbsp; Verify that the name on the zip entry - in particular the filename extension -&nbsp;is the same as the name of the file you downloaded directly.&nbsp; if the name doesn't agree, then you have a naming problem.&nbsp; </li>\r\n<li>open the zip again, programmatically, unzip the entry you added, and compare the bytes received there, with the bytes directly downloaded.&nbsp; Same size?&nbsp; Same content?&nbsp; If not then something is changing them. </li>\r\n</ul>\r\n<p>I don't know what you mean by &quot;it gives the message that the document format is not supported&quot;.&nbsp; What is &quot;it&quot; that is giving you this message?&nbsp; How are you opening the zip file?&nbsp; Are you sure the name attached to the zip entry is appropriate for the content?&nbsp; In Windows the extension of the file dictates how it will be opened.&nbsp; A .pdf file is treated as an Adobe Acrobat file., for example.&nbsp; If you put regular text content into a file, name it with a .pdf extension, and then try to open it by double clicking in explorer, explorer will complain about a corrupt file.&nbsp; My point is that if the extension on the filename is not consistent with the content within the file, you can get a message similar to what you described.&nbsp;</p>\r\n<p>-Cheeso</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-07T06:13:19.703-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "264835",
    "ThreadId": "77080",
    "Html": "<p>Currently what I am doing is</p>\r\n<ul>\r\n<li>I am downloading the file from the url using the web client's DownloadFile() method into a temporary folder.</li>\r\n<li>Using the AddFile() method in DotNetZip I add the file passing its temporary folder's filepath as the parameter to the AddFile() method.</li>\r\n<li>Using the Save() method in DotNetZip I save it.</li>\r\n</ul>\r\n<p>In this way all the files are zipped into a zip file.</p>\r\n<p>When i check the contents of the temporary folder all the files and its contents are in the correct formats irrespective of file type.</p>\r\n<p>However when I open the zipped file and double click on a file other than a .txt file an incorrect format message is given and on opening the file its contents are not in the right format.</p>\r\n<p>To cross check the contents of the Zipped file I programmatically unzipped the zipped file .All the unzipped files were now in the correct format with the right contents.</p>\r\n<p>&nbsp;</p>\r\n<p>Any ideas why this change occurs?</p>\r\n<p>Ps: I have saved the files with the right file extentions and the contents of the files are in sync with their respective file types.</p>\r\n<p>Thanks</p>\r\n<p>Elizabeth</p>",
    "PostedDate": "2009-12-08T02:08:43.883-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "264880",
    "ThreadId": "77080",
    "Html": "<blockquote style=\"border:solid .1em #ccc;font-style:italic;margin:.25em 1em 0 1em;padding:0 .25em 0 .25em\">\r\n<p>However when I open the zipped file and double click on a file other than a .txt file an incorrect format message is given and on opening the file its contents are not in the right format.</p>\r\n<p>To cross check the contents of the Zipped file I programmatically unzipped the zipped file .All the unzipped files were now in the correct format with the right contents.</p>\r\n</blockquote>\r\n<p>If you can unzip the files programmatically, and then open them, that would suggest that the content is correct within the zip file. &nbsp;</p>\r\n<p>you didn't say what you use to &quot;open the zipped file and double click&quot;. Explorer?</p>\r\n<p>You might try to open a zipped file from another source, and double-click, and see what happens.</p>",
    "PostedDate": "2009-12-08T04:30:55.78-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "264882",
    "ThreadId": "77080",
    "Html": "<p>I am saving the zipped file on my desktop so I am double clicking on this zipped file when an incorrect format message is given and then</p>\r\n<p>when i proceed to open the file its contents are not in the right format.</p>\r\n<p>I am sorry but I did not understand what you meant in the last statement.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-08T04:40:24.547-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "264914",
    "ThreadId": "77080",
    "Html": "<p>Are you saying that the error message occurs when you double-click the zip file itself?</p>",
    "PostedDate": "2009-12-08T06:12:52.643-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "265202",
    "ThreadId": "77080",
    "Html": "<p>No, it happens after I have opened the zip file by double-clicking the zip file.Then when I click on an individual file in the zip file of any file type other than .txt type</p>\r\n<p>an incorrect format message is given and then when i proceed to open the file its contents are not in the right format.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-08T23:48:42.5-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "265279",
    "ThreadId": "77080",
    "Html": "<p>Hi,</p>\r\n<p>&nbsp;</p>\r\n<p>The problem is resolved. It seemed to have been a machine specific problem so on running the code on other systems the code works fine .</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks for all the help</p>\r\n<p>Elizabeth</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-09T04:25:27.16-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]