[
  {
    "Id": "235953",
    "ThreadId": "69353",
    "Html": "<p>I noticed the ZipFile is not serializable.</p>\r\n<p>We would like to expose the zipfile via webservice to a client, just wondering if you happen to any suggestions/workaround to achieve this.</p>\r\n<p>Thanks</p>\r\n<p>NP</p>",
    "PostedDate": "2009-09-18T02:18:51.23-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "236181",
    "ThreadId": "69353",
    "Html": "<p>What do you mean by &quot;expose the zipfile&quot;?</p>\r\n<p>what exactly is involved in exposing a zipfile to a client via a web service?</p>",
    "PostedDate": "2009-09-18T12:03:59.11-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "236348",
    "ThreadId": "69353",
    "Html": "<p>Sorry about the confusion. I meant to say sending the zip file via a web service.</p>\r\n<p>If i try to serialize the zip file i get an exception indicating it is not serializable.</p>\r\n<p>Thanks</p>\r\n<p>NP</p>",
    "PostedDate": "2009-09-18T22:58:40.117-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "236349",
    "ThreadId": "69353",
    "Html": "<p>If the zipfile is in memory, why don't you send it as a stream?&nbsp;</p>\r\n<p>If the zipfile is on the filesystem, you can just read the file and send it as you would any file.</p>\r\n<p>I don't understand why you want&nbsp;to send a ZIpFile object.</p>\r\n<p>Can you explain your scenario again please?&nbsp; what is it that you really want to do?&nbsp; Are you trying only to send a compressed data stream across the wire?</p>\r\n<p>if that's the case why a zipfile?&nbsp; Why not just use a DeflateStream or ZlibStream or GZipStream ?</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-18T23:11:44.777-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "236735",
    "ThreadId": "69353",
    "Html": "<blockquote style=\"border:solid .1em #ccc;font-style:italic;margin:.25em 1em 0 1em;padding:0 .25em 0 .25em\"><strong>Cheeso wrote:</strong><br>\r\n<p>If the zipfile is in memory, why don't you send it as a stream?&nbsp;</p>\r\n<p>If the zipfile is on the filesystem, you can just read the file and send it as you would any file.</p>\r\n<p>I don't understand why you want&nbsp;to send a ZIpFile object.</p>\r\n<p>Can you explain your scenario again please?&nbsp; what is it that you really want to do?&nbsp; Are you trying only to send a compressed data stream across the wire?</p>\r\n<p>if that's the case why a zipfile?&nbsp; Why not just use a DeflateStream or ZlibStream or GZipStream ?</p>\r\n<p>&nbsp;</p>\r\n</blockquote>\r\n<p>Thanks Cheeso for that.</p>\r\n<p>&gt;&gt;Are you trying only to send a compressed data stream across the wire?</p>\r\n<p>Yes, this is exactly what i am trying to do as the zip file may contain a large number of files.</p>\r\n<p>To be able to send in a web service the objects need to be serializable.</p>\r\n<p>I will look into the streams as you said and see if it would help.</p>\r\n<p>Thanks</p>\r\n<p>NP</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-20T20:30:16.033-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "236986",
    "ThreadId": "69353",
    "Html": "<blockquote style=\"border:solid .1em #ccc;font-style:italic;margin:.25em 1em 0 1em;padding:0 .25em 0 .25em\"><strong>pathurun wrote:</strong><br>\r\n<blockquote style=\"border:solid .1em #ccc;font-style:italic;margin:.25em 1em 0 1em;padding:0 .25em 0 .25em\"><strong>Cheeso wrote:</strong><br>\r\n<p>If the zipfile is in memory, why don't you send it as a stream?&nbsp;</p>\r\n<p>If the zipfile is on the filesystem, you can just read the file and send it as you would any file.</p>\r\n<p>I don't understand why you want&nbsp;to send a ZIpFile object.</p>\r\n<p>Can you explain your scenario again please?&nbsp; what is it that you really want to do?&nbsp; Are you trying only to send a compressed data stream across the wire?</p>\r\n<p>if that's the case why a zipfile?&nbsp; Why not just use a DeflateStream or ZlibStream or GZipStream ?</p>\r\n<p>&nbsp;</p>\r\n</blockquote>\r\n<p>Thanks Cheeso for that.</p>\r\n<p>&gt;&gt;Are you trying only to send a compressed data stream across the wire?</p>\r\n<p>Yes, this is exactly what i am trying to do as the zip file may contain a large number of files.</p>\r\n<p>To be able to send in a web service the objects need to be serializable.</p>\r\n<p>I will look into the streams as you said and see if it would help.</p>\r\n<p>Thanks</p>\r\n<p>NP</p>\r\n<p>&nbsp;</p>\r\n</blockquote>\r\n<p>&nbsp;funny this is almost what i am doing from the sound of it.</p>\r\n<p>here are some snips of code:</p>\r\n<p>on hh that gets a zip:<span style=\"font-size:xx-small\"><span style=\"font-size:xx-small\">\r\n<p>&nbsp;</p>\r\n&lt;font size=&quot;1&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span>\r\n<p><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\">string</span></span><span style=\"font-size:xx-small\"> Base64Text = </span><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\">string</span></span><span style=\"font-size:xx-small\">.Empty;<br></span><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\">byte</span></span><span style=\"font-size:xx-small\">[] Raw = { 0, 0, 0, 0 };</span></p>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-size:xx-small\">&lt;font size=&quot;1&quot;&gt;\r\n<p>Base64Text = Srv.GetUpdateInfo(</p>\r\n&lt;/font&gt;</span></p>\r\n<p><span style=\"font-size:xx-small\">);&nbsp; // web method call<br></span><span style=\"font-size:xx-small\"><span style=\"font-size:xx-small\">Raw = </span><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">Convert</span></span><span style=\"font-size:xx-small\">.FromBase64String(Base64Text);<br></span><span style=\"font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">FileStream</span></span><span style=\"font-size:xx-small\"> Fs = </span><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">File</span></span><span style=\"font-size:xx-small\">.Create(</span><span style=\"color:#a31515;font-size:xx-small\"><span style=\"color:#a31515;font-size:xx-small\">&quot;\\\\FlashDisk\\\\Up\\\\Update.Zip&quot;</span></span><span style=\"font-size:xx-small\">, Raw.Length / 8);<br>Fs.Write(Raw, 0, Raw.Length);<br>Fs.Flush();<br>Fs.Close();<br>data is now on hh flash disk as a zip file.</span></span></span></p>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-size:xx-small\"><span style=\"font-size:xx-small\"><span style=\"font-size:xx-small\"><span style=\"font-size:xx-small\">&lt;font size=&quot;1&quot;&gt;\r\n<p>On Server to send data:</p>\r\n&lt;/font&gt;</span>\r\n<p><span style=\"color:#0000ff;font-size:xx-small\"></span></p>\r\n<p><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"font-size:xx-small\">[</span><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">WebMethod</span></span><span style=\"font-size:xx-small\">]<br></span><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\">public</span></span><span style=\"font-size:xx-small\"> </span><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\">string</span></span><span style=\"font-size:xx-small\"> GetUpdate(</span><span style=\"font-size:xx-small\">) {<br></span>string </span></span><span style=\"font-size:xx-small\">datastring = </span><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\">string</span></span><span style=\"font-size:xx-small\">.Empty;<br></span><span style=\"font-size:xx-small\">datastring = </span><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">Convert</span></span><span style=\"font-size:xx-small\">.ToBase64String(<br>System.IO.</span><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">File</span></span><span style=\"font-size:xx-small\">.ReadAllBytes(<br></span><span style=\"color:#0000ff;font-size:xx-small\"><span style=\"color:#0000ff;font-size:xx-small\">this</span></span><span style=\"font-size:xx-small\">.Server.MapPath(<br></span><span style=\"color:#a31515;font-size:xx-small\"><span style=\"color:#a31515;font-size:xx-small\">&quot;~/App_Data/Update.&quot;</span></span><span style=\"font-size:xx-small\"> + </span><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">WebConfigurationManager</span></span><span style=\"font-size:xx-small\">.AppSettings[</span><span style=\"color:#a31515;font-size:xx-small\"><span style=\"color:#a31515;font-size:xx-small\">&quot;CurrentVersion&quot;</span></span><span style=\"font-size:xx-small\">] + </span><span style=\"color:#a31515;font-size:xx-small\"><span style=\"color:#a31515;font-size:xx-small\">&quot;.zip&quot;</span></span><span style=\"font-size:xx-small\">)<br>),</span><span style=\"color:#2b91af;font-size:xx-small\"><span style=\"color:#2b91af;font-size:xx-small\">Base64FormattingOptions</span></span><span style=\"font-size:xx-small\">.InsertLineBreaks);\r\n<p>&nbsp;</p>\r\n<p>return datastring;<br>}</p>\r\n&lt;font size=&quot;1&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;font size=&quot;1&quot;&gt;\r\n<p>thats one way to do this for a file on disk to download to a hh device.</p>\r\n&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;</span></p>\r\n&lt;font size=&quot;1&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;font size=&quot;1&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;</span>&lt;font size=&quot;1&quot;&gt;&lt;font size=&quot;1&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;&lt;/font&gt;</span>&lt;font size=&quot;1&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span></p>\r\n<p>&nbsp;</p>\r\n</span></p>",
    "PostedDate": "2009-09-21T11:20:47.277-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237016",
    "ThreadId": "69353",
    "Html": "<p>If you are transmitting a large file, you might want to look into <a href=\"http://msdn.microsoft.com/en-us/library/ms731913.aspx\">streaming the file content</a>.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-21T12:53:25.98-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237018",
    "ThreadId": "69353",
    "Html": "<p>I haven't done this, but if I were building it, I would first try this:</p>\r\n<p>define a service contract that allowed the client to provide a stream to the server.&nbsp; The stream on the client might be a filestream or a memory stream.&nbsp; The server would then produce the zip file and then save it to the stream provided by the client.&nbsp; The client can then do what it wants with the zip content.</p>\r\n<p>If that does not work, for whatever reason, a simple file transfer approach would also work.&nbsp; Here again I'd use streaming though, to avoid the requirement that all zip content be kept in memory.</p>\r\n<p>if you're not concerned about keeping all the content in memory at one time , then use the approach given above, by figuerres, where the content is sent all as one large base64 string.&nbsp;&nbsp;Encoding it that way&nbsp;will inflate the data on the wire significantly, so I'd recommend that only for small zip files, and when performance is not a concern.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-21T13:00:45.28-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237203",
    "ThreadId": "69353",
    "Html": "<p>Thanks very much for your input Cheeso and Figurres. I will give it a try and see how it works.</p>\r\n<p>Thanks</p>\r\n<p>NP</p>",
    "PostedDate": "2009-09-22T01:30:19.203-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "238506",
    "ThreadId": "69353",
    "Html": "<blockquote style=\"border:solid .1em #ccc;font-style:italic;margin:.25em 1em 0 1em;padding:0 .25em 0 .25em\"><strong>Cheeso wrote:</strong><br>\r\n<p>I haven't done this, but if I were building it, I would first try this:</p>\r\n<p>define a service contract that allowed the client to provide a stream to the server.&nbsp; The stream on the client might be a filestream or a memory stream.&nbsp; The server would then produce the zip file and then save it to the stream provided by the client.&nbsp; The client can then do what it wants with the zip content.</p>\r\n<p>If that does not work, for whatever reason, a simple file transfer approach would also work.&nbsp; Here again I'd use streaming though, to avoid the requirement that all zip content be kept in memory.</p>\r\n<p>if you're not concerned about keeping all the content in memory at one time , then use the approach given above, by figuerres, where the content is sent all as one large base64 string.&nbsp;&nbsp;Encoding it that way&nbsp;will inflate the data on the wire significantly, so I'd recommend that only for small zip files, and when performance is not a concern.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n</blockquote>\r\n<p>&nbsp;i am fairly sure that for an asmx or wcf over http that http will send the data in chunks as http packets, i guess the issues would be the use of .ReadAllBytes ....&nbsp;&nbsp; one could read a chunk and send it with a seq number... then the reciving side could get 1, get 2, get 3 and so on....</p>\r\n<p>the .net cf limits a lot of what we can do with wcf and stuff..... I *WISH* they had put in support for WCF over sockets with Binary serialization!&nbsp; I have about 80 devices that all upload data every day.... https soap is kinda big chunks.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-24T13:51:08.75-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]