EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Can the ZipWriter handle files with same file name

Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.
#19816
Posted: 04/17/2012 06:22:20
by Niklas Kjellander (Standard support level)
Joined: 09/30/2008
Posts: 49

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;
zipWriter.CreateArchive();
zipWriter.Add(@"C:\test1\file1.txt");
zipWriter.Add(@"C:\test2\file1.txt");
zipWriter.Compress(@"C:\test.zip");

Is this scenario supported by the ZipWriter?
#19817
Posted: 04/17/2012 06:40:03
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

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

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?
#19819
Posted: 04/17/2012 10:48:12
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

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.

Reply

Statistics

Topic viewed 544 times

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




|

Back to top

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

Got it!