EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Can the ZipWriter handle files with same file name

Posted: 04/17/2012 06:22:20
by Niklas Kjellander (Standard support level)
Joined: 09/30/2008
Posts: 54

I'm using the .Net libraries and what I want to do is to add two or more files with same file name (they are located in different directories on disk) to a directory in a new zip archive.

The ZipWriter has a property called ReplaceMode. I've tried to set it to Never, but it didn't work.

Example code:
TElZipWriter zipWriter = new TElZipWriter();
zipWriter.ReplaceMode = SBArcBase.TSBArcReplaceMode.armNever;

Is this scenario supported by the ZipWriter?
Posted: 04/17/2012 06:40:03
by Vsevolod Ievgiienko (Team)

Thank you for contacting us.

Try to use TElZipWriter.Add(System.IO.Stream Stream, string FileName) twice with the same FileName parameter.
Posted: 04/17/2012 07:07:28
by Niklas Kjellander (Standard support level)
Joined: 09/30/2008
Posts: 54

Yes, the overload of Add with stram as argument works. However it adds the complexity of managing the streams while adding files to the archive and disposing them after the compression is done.

Is it a bug in the overload of the Add method that takes a Path as argument?
Any chance it will be fixed soon?
Posted: 04/17/2012 10:48:12
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 442

Hi. Replace mode 'never' means that if file exists in archive it will not be replaced. And this works while adding files via their names, and in such situation you cannot add files with the same name (btw, what is the logic in adding files with the same name?).
If you add items from streams, always a new entry is created.



Topic viewed 628 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!