。C#/。NET:创建一个CAB,没有外部库将文件添加到它 [英] C#/.NET: Creating a CAB and adding files to it without an external library

查看:134
本文介绍了。C#/。NET:创建一个CAB,没有外部库将文件添加到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一个<一个href="http://stackoverflow.com/questions/510648/managed-$c$c-library-to-write-read-cabinet-cab-files">similar问题但标注的答案提供了一个链接到外部库,需要多个相关性要在用户的计算机上安装。

I'm aware there is a similar question but the marked answer provides a link to an external library which requires several dependencies to be installed on the user's machine.

我不需要提取或其他任何花哨的像上市文件 - 我只需要一个文件夹的全部内容添加到一个CAB文件。我知道CABINET.DLL存在在\ Windows \ System32文件夹中,我希望有一个简单的方法来使用这个DLL进行交互,实现我想要做的事情。

I don't need extraction or anything else fancy like listing files - I only need to add the entire contents of a folder to a single cabinet file. I know cabinet.dll exists in the \Windows\System32 folder and I'm hoping there's a simple way to interact with this DLL to achieve what I'm trying to do.

是否有可能做到这一点无需外部库?如果任何人都可以点我在正确的方向,我会感激不尽。

Is it possible to do this without an external library? If anyone could point me in the right direction I'd be eternally grateful.

推荐答案

您可以看看维克斯更具体在 Microsoft.Deployment.Com pression.Cab 组装。它有一个很好的API,可以让你做到这一点:

You may take a look at WiX and more specifically the Microsoft.Deployment.Compression.Cab assembly. It has a nice API that allows you to do this:

CabInfo cab = new CabInfo(@"c:\Work\some.cab"); 
cab.Pack(@"C:\Work\folder");

这是依赖于 Microsoft.Deployment.Com pression 组件,它是独立的,所以你将只需要这两个组件。

It's dependent on the Microsoft.Deployment.Compression assembly which is standalone so you will need only those two assemblies.

这篇关于。C#/。NET:创建一个CAB,没有外部库将文件添加到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆