English 中文(简体)
压缩文档的特定部分
原标题:Loading specific section of a compressed file stream

我们在应用中拥有一个简单的双向文档格式(C# .NETWindows App)。 格式基本上简短,表明标的类型,然后是标的指南(说明),然后是任何物体特定数据(说明内容)。 我们希望能够把许多物体储存在同一档案中(并大体;10000),但在某些情况下,只需要装载。 我们的解决办法是,在档案中保留目标地点索引,这样,当我们开始撰写新物体时,我们就把目标开始放在档案中。 当我们想装上这个物体时,我们利用这个指数化的位置来装上重新设计的数据。 罚款。

然而,如果我们想压缩档案,这种方法是否仍然有可能? 我对压缩工作,特别是我们计划使用的GZipStream班(System.IO.Compression)不感到太热。 根据我的理解,这一类人不支持寻找财产或职位财产。 是否仍有可能使用底土木 File(不作gues)的“求学”和立场? 从根本上说,我们是否可以有一份压缩的档案,如果能够的话,我们可以有选择地从我们怎样做呢?

感谢

Steve

最佳回答

否,如果你想要获得在未压缩数据中的具体位置,你至少必须暂时予以压缩。

问题回答

这不是一项真正的努力,但解决办法是:

  • keep a track of your position in the file (probably best done by implementing a "myBinaryReader" which inherits from BinaryReader)
  • if you are Seeking a position forward from your current position - ReadBytes until you get there.
  • if you are Seeking a position prior to your current position - reopen the file for a decompressed read (which resets your current position to zero), and then ReadBytes until you get to where you want to be.

Obviously this is not at all an ideal solution, but it may still give acceptable performance. In my case, the compressed file fits easily within memory (uncompressed does not), so I have loaded the compressed file into memory.

理想的情况是,将改变离心的阶层,以支持真正的寻求。

更好的解决办法:

利用GZipStream在记忆中制造压缩机,然后写上你自己的班子,以控制这种照相和写成磁盘(高潮使用压缩机)。 并用磁盘书写本级的数据。

然后,你可以确保基本的磁盘流支持。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签