This project is read-only.

Zip.AddFiles method with Relative Path parameters

Mar 1, 2010 at 4:08 PM


is there a way to add files to a Zip using a relative Path parameters (remove relative Path from File Path) ?

Perhaps it's already available but I didn't find It.

For Sample, I have an string[] table that contain the following Files:

D:\\testing-directory\\G123456\\Intl\\Batch x update x\\IT\\Clean\\Log\\list1.rtf
D:\\testing-directory\\G123456\\Intl\\Batch x update x\\IT\\Clean\\Log\\DOC\\Test\\list2.rtf
D:\\testing-directory\\G123456\\Intl\\Batch x update x\\IT\\Clean\\Log\\Prep\list3.rtf
D:\\testing-directory\\G123456\\Intl\\Batch x update x\\IT\\Clean\\Log\\LGP\\DOC\\Test\\list4.rtf
D:\\testing-directory\\G123456\\Intl\\Batch x update x\\IT\\Clean\\Log\\For sample\\list5.rtf

and wanted to remove inside the Zip the Path : D:\\testing-directory\\G123456\\Intl\\Batch x update x\\IT\\Clean

so to have a zip that look like that:

Log\\For sample\\list5.rtf

is there a way to do that from string table without creating a Foreach loop ?


Mar 1, 2010 at 7:03 PM

if you want all the files in the directory hierarchy, you can call AddDirectory() and specify a directoryInArchive argument.  You can also do this with AddSelectedFiles(). 

You can call AddFiles(), and then use a for loop to trim the path for each added entry.

Or, you can use a single loop, calling AddFile() within the loop, and specifying the directory for each file that way.

You said something about not using a for loop; I don't know why you'd want to avoid that.

Mar 2, 2010 at 10:22 AM

Thanks for your answer.

I cannot use the AddDirectory() or AddSelectedFiles() method as I already have the set of files in a String table.

In my point of view, when you have a set of Files in an array list or string Table it will be interesting that the AddFiles() method do the loop for us and in that way, remove the relative Path from Files Path.

Like the sample provided above.

tell me what do you think about this.





Mar 2, 2010 at 1:23 PM

A simple for loop will accomplish it for you, correct?

Thanks and good luck.

Mar 2, 2010 at 1:28 PM

Yes it's what I did, but I thought that it could be integrated into a method

Thanks for your help