Pregunta

I never done this but I am develping a simple application and really need some help.

The scenario is that I have some excel files which are all name coded, I need to get the first 5 letters of each files and compress those together. Ex.

MARKS MARKS 2 MARKS 3

These all compress.

Is their any method to do this and zip with winrar.

Thanks

¿Fue útil?

Solución

I agree IonicZip (now dotnetzip) is good. here is the sample of what you want to do

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

Otros consejos

I use Ionic Zip in my project. API call is very easy. You can simply zip your files.

 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");
 }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top