Winrar使用C#压缩文件

Winrar使用C#压缩文件,c#,compression,zip,winrar,C#,Compression,Zip,Winrar,我从来没有这样做,但我正在开发一个简单的应用程序,真的需要一些帮助 这个场景是,我有一些excel文件,它们都是名称编码的,我需要得到每个文件的前5个字母,并将它们压缩在一起。前 标记 马克2 马克3 这些都是压缩的 他们的任何方法都可以做到这一点,并使用winrar压缩 谢谢我在我的项目中使用。API调用非常简单。你可以简单地压缩你的文件 using (ZipFile zip = new ZipFile()) { // add this map file into the "im

我从来没有这样做,但我正在开发一个简单的应用程序,真的需要一些帮助

这个场景是,我有一些excel文件,它们都是名称编码的,我需要得到每个文件的前5个字母,并将它们压缩在一起。前

标记 马克2 马克3

这些都是压缩的

他们的任何方法都可以做到这一点,并使用winrar压缩

谢谢我在我的项目中使用。API调用非常简单。你可以简单地压缩你的文件

 using (ZipFile zip = new ZipFile())
 {
     // add this map file into the "images" directory in the zip archive
     zip.AddFile(@"C:\Users\kth\Desktop\dll\MARKS.xl", "images");

     zip.Save("MyZipFile.zip");
 }
我同意(现在的dotnetzip)是好的。这是你想做的事情的例子

        string somepath = "D:\\ExcelFiles";
        string zippath = "D:\\ExcelFiles\\some.zip";
        string[] filenames =
        System.IO.Directory.GetFiles(somepath, "Mark*.xlsx", SearchOption.AllDirectories);

        using (ZipFile zip = new ZipFile())
        {
            foreach (String filename in filenames)
            {

                ZipEntry e = zip.AddFile(filename, "");

            }
            zip.Save(zippath);
        }