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:
Add(FileSet set)
Add(FileSet set, string archiveDirectoryPath)
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)