I want to download a single file in a remote Zip file that is in the cloud. The zip file is too large for me to download as a whole therefore I have decided to look for a way to download only a single file(XML) that I need within the archive. I have tried and Tested a webclient and web request but it downloads the whole zip file(also too large file for these technuques usually fails). I'm eyeing the SharpZipLib but I dont know how to use it. Is it the right library I should use or there are other available ones I can get and test. Thank you so much.
Asked
Active
Viewed 564 times
3
-
It is impossible to download just one file from a ZIP unless u extract/unpack it...So,that's what u should go for :) – Software Dev Mar 26 '18 at 03:23
-
This is not possible. Also, [What topics can I ask about here?](http://stackoverflow.com/help/on-topic) says quite clearly that you cannot ask for library recommendations here. – Ken White Mar 26 '18 at 03:24
-
@KenWhite , I agree that one shouldn't ask about library recommendations here,but the reason OPs still ask these is maybe because there are a lot of recommendations posts on SO that have a lot of upvotes.....I don't understand why they were upvoted ? Like [this one](https://stackoverflow.com/questions/2654932/create-excel-files-from-c-sharp-without-office) – Software Dev Mar 26 '18 at 03:45
-
@KenWhite It might be possible if remote server allows to request parts of the file (via the Range http header), and also allows to get content length without actual contents (via HEAD request). – Evk Mar 26 '18 at 06:35
-
@Evk how is this possible ? – OneLazy Mar 26 '18 at 06:44
-
2If you read zip format specification (even vague one, like in wikipedia: https://en.wikipedia.org/wiki/Zip_(file_format)), you'll see that there is "End of central directory record" at the end of zip file. So first you request length of file via HEAD request, then you find that EOCD record via Range request(s), and from there you can find offset and length of target entry and download only that via another Range request. It's unlikely that there are available tools to do that for you though, so you'll have to implement that yourself. – Evk Mar 26 '18 at 06:47
-
@zackraiyan: There are lots of old posts here that are highly upvoted that would be off-topic today. Many new sites have been created (such as [su], [sf], etc.) that did not exist when those questions were asked. In addition, guidelines evolve over time, and the only ones relevant are those that are in effect at the time the question is asked, and the current guidelines say you cannot ask for recommendations for libraries, tool, books, tutorials or other off-site resources here. – Ken White Mar 26 '18 at 12:22
-
@Evk: Even if you did jump through all the hoops (EOCD record, downloading a range), you'd still end up with the compressed content without the information required to decompress it. – Ken White Mar 26 '18 at 12:30
-
@Evk,it is not possible again , i once tried something like this but in vain :( – Software Dev Mar 26 '18 at 12:45
-
1@KenWhite I don't agree. EOCD points to list of central file headers. Each such header contains pointer to local file header. This header contains all information necessary to decompress content (such as compression method used) and is immediately followed by compressed content. So 3 range lookups (if we are lucky to find EOCD with a first one) should be enough to download and decompress specific file. – Evk Mar 26 '18 at 12:45