C#/.NET: Creating a CAB and adding files to it without an external library

前端 未结 2 1048
后悔当初
后悔当初 2020-12-21 00:35

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 machin

2条回答
  •  暖寄归人
    2020-12-21 01:27

    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");
    

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

提交回复
热议问题