0

I have a URL that returns a zip file, and when I extract the content, it has lots of xml files inside. I need to read the files one by one, but I can not, never, use the HD, I must do everything in cache. Is it possible?

The other solutions that I've seen they all saves the downloaded file in a path.

There is this other post: How can I unzip a file to a .NET memory stream?, that gets close to answering my question, but in this case, they already have the ziped file save.

I my case I need to download, unzip, and read its content.

Gui Oliveira
  • 155
  • 2
  • 9
  • What if the content does not fit into memory? Are you aware that most programs (if not all?) will decompress your zip to a temp location anyway? – MakePeaceGreatAgain May 24 '19 at 13:19
  • No I wasn't aware of that. So If I need to unzip, It will always use a temp location, I can not do that in memory? – Gui Oliveira May 24 '19 at 13:23
  • Have a look at this post: https://stackoverflow.com/questions/22604941/how-can-i-unzip-a-file-to-a-net-memory-stream – MakePeaceGreatAgain May 24 '19 at 13:31
  • Ok I will take a look... Just a note: in my case the zip file size is 8B, so I may be risking it not fitting in memory. – Gui Oliveira May 24 '19 at 13:43
  • I this post that you have shared, they already have a zip file saved, and they just unzip in memorystream. I my case case I need to download, unzip and read its content. – Gui Oliveira May 24 '19 at 13:45
  • You can use an [HttpClient to call GetStream()](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.getstreamasync?view=netframework-4.8). You can then copy from this stream to a MemoryStream (instead of a stream that writes to a file). Then, you can use the other post to figure out how to read the zip file. – corranrogue9 May 24 '19 at 17:16

0 Answers0