Quantcast
Channel: Rebex Q&A Forum - Recent questions and answers
Viewing all articles
Browse latest Browse all 3862

Answered: Strange 0, 1 og 2 rootfolder in zip-file

$
0
0

Thank you for the code. I found that the problem is in your code.
Actually, it is caused by "unhandy" tolerance of VB.NET which allows to pass nonstring variables to string parameters. Your code wouldn't be compiled if written in C#.

Please see declarations of the Add method with FileSet argument:

  1. Add(FileSet set)
  2. Add(FileSet set, string archiveDirectoryPath)
  3. Add(FileSet set, string archiveDirectoryPath, TransferMethod transferMethod, ActionOnExistingFiles defaultActionOnExistingFiles)

You used this:
archive.Add(fileSet, TraversalMode.MatchFilesShallow, TransferMethod.Copy, ActionOnExistingFiles.OverwriteAll)

Because of VB.NET, second parameter was implicitly cast to string in runtime and third method was used. In case of TraversalMode.MatchFilesShallow a string "2" was passed (which leads to creation of root folder "2").

The correct solution is to call the method like this:
archive.Add(fileSet, "/", TransferMethod.Copy, ActionOnExistingFiles.OverwriteAll)


Viewing all articles
Browse latest Browse all 3862

Trending Articles