本文介绍了使用C#解压缩tar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一种方式来嵌入资源添加到我的解决方案。这种资源将有很多在其中的文件夹。用户的需求,他们需要解压缩。

I'm searching a way to add embedded resource to my solution. This resources will be folders with a lot of files in them. On user demand they need to be decompressed.

我在寻找一种方式都存放在可执行文件夹等不涉及第三方库(看起来相当愚蠢,但是这是任务)。

I'm searching for a way do store such folders in executable without involving third-party libraries (Looks rather stupid, but this is the task).

我发现,我能gzip和UnGZip他们使用标准库。但GZip压缩只处理一个文件。在这种情况下,应西藏自治区来到现场。但我还没有找到标准类之间TAR的实现。

I have found, that I can GZip and UnGZip them using standard libraries. But GZip handles single file only. In such cases TAR should come to the scene. But I haven't found TAR implementation among standard classes.

也许可以解压缩TAR裸C#?

Maybe it possible decompress TAR with bare C#?

推荐答案

既然你不能使用以外的图书馆,你是不是仅限于焦油文件无论是。事实上,他们甚至都不需要它都在同一个文件中。

Since you are not allowed to use outside libraries, you are not restricted to a specific format of the tar file either. In fact, they don't even need it to be all in the same file.

您可以编写自己的焦油状工具在走一个目录树C#,并产生两个文件:一个头文件,该文件包含一个序列字典映射的 System.IO.Path 实例到偏移/长度对,以及含有该含量大的文件单个文件连接成一个巨大的一滴。这不是一个简单的任务,但它不是太复杂无论是。

You can write your own tar-like utility in C# that walks a directory tree, and produces two files: a "header" file that consists of a serialized dictionary mapping System.IO.Path instances to an offset/length pairs, and a big file containing the content of individual files concatenated into one giant blob. This is not a trivial task, but it's not overly complicated either.

这篇关于使用C#解压缩tar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 07:18