Search in Directory C:\

Oct 13, 2011 at 6:36 PM

I am trying to implement a code that filter some files from the driver C:, but I am getting no files returned in my zip.

Here is my code:

ZipFile zip = new ZipFile();

zip.AddSelectedFiles("*.mp3", @"C:\", true);

zip.Save("C:\\teste.zip");

 

My zip ends up with no files, but I do have files with .mp3 extension.

Does anyone know what the problem is?

Thanks.

Coordinator
Oct 13, 2011 at 6:41 PM

I don't know but, to find out you might try the FileSelector class, also included in the DotNetZip library.  you may be able to do some tests with it to figure out why you are seeing the behavior you are seeing.

By the way, compressing MP3 files is not a productive activity. They are already compressed.

 

Oct 13, 2011 at 7:03 PM

Hi Cheeso,

mp3 file is just an example. I am filtering some others extensions in my application.

The problem is the directory to search, when I pass "C:\MyDirectory" for example it works fine. But when I pass the whole driver C: anything happens.

This code works fine:

ZipFile zip = new ZipFile();
                        
zip.AddSelectedFiles("*.mp3", @"C:\PastaTeste", true);

zip.Save("C:\\teste.zip");

 

Oct 13, 2011 at 7:29 PM

Hi,

I resolved the problem using the FileSelector class. Here is the code:

 

ZipFile zip = new ZipFile();

FileSelector fs = new FileSelector("*.mp3");            
zip.AddFiles(fs.SelectFiles(@"C:\", true), true, "C");           

zip.Save("C:\\teste.zip");

 

Thanks for the answer.