Question

In my current project i'm dealing with a huge number of files (over tens of milliard files with low volume-between 1 and 30 KB) as resources which copying them for my customer is time consuming job. i'm searching for a packaging mechanism that can help me to package each 1000 or 10000 one of them into a single file,resulting more copy speed because in that case i'm dealing with much less count of files; and also reading them from my application should not need any extraction and also no compression while i'm writing or changing them (because of the performance and nature of application which is distributed and resources are being shared between clients),I have searched and i know about following ZIP libraries:

  • SharpZipLib
  • DotNetZip
  • System.IO.Packaging

But seems above libraries need to be -at least- iterated through files to access a file in the zip or package without extraction. i need to access the files via their address (folder structure hierarchy) in the zip or package file! following links are similar questions which are answered via Iterating through the zip file:

how-to-read-data-from-a-zip-file-without-having-to-unzip-the-entire-file

content-inside-zip-file

Has anyone any idea or solution about this issue?

By the way,i'm coding in C# and the project is windows form-based.

Was it helpful?

Solution

I would do my own Package Format. With GZipStream or something else. For each files, you compress them with GZipStream, after you get the bytes values and you need to create a header in your Package Format which contains for each files (name, starting position and length). With this data in your header, that will probably by at the beginning of your package. You can get the information for your wanted file and after you just seek to the position of the compressed data, you get the byte array with the specified length.

But if you modify one files, you will need to recalculate all index after the modified files.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top