Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET SFX extration directory question

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20148 |

    I am pretty new to the Xceed toolkit and I am evaluating if the SFX component in Xceed can replace the current tool we use to create self extracting exe files.

    I have made a test project and got everything working with the exception of one thing.  I cannot figure out how to make the exe file which my code creates extract to the directory which the user chose after launching the exe.  For example, in code set the DefaultDestinationFolder to be c:\x, and when the exe runs I change that to be c:\test. What happens is that c:\test is created, however, so is c:\x and the files are extract to c:\x.

    The code I am using pretty much out of the examples, this is the portion that is creating the exe file:

                ZipArchive zip = new ZipArchive(new DiskFile(exeName));
                XceedSfxPrefix sfx = new XceedSfxPrefix(new DiskFile(@”C:\Program Files\Xceed Components\Bin\Sfx\xcdsfx32.bin”));

                sfx.DialogStrings[DialogStrings.Title] = dialogTitle;
                sfx.DialogMessages[DialogMessages.Introduction] = dialogMsg;
                sfx.DefaultDestinationFolder = extractionDirectory;
                sfx.ExistingFileBehavior = ExistingFileBehavior.OverwriteOlderOnly;
     

                 using (AutoBatchUpdate update = new AutoBatchUpdate(zip))
                {
                    zip.SfxPrefix = sfx;
                    DiskFolder folder = new DiskFolder(srcDir);
                    ZippedFolder destinationFolder = null;

                    destinationFolder = (ZippedFolder)zip.GetFolder(extractionDirectory);
     
                    if (!destinationFolder.Exists)
                        destinationFolder.Create();

                    folder.CopyTo(destinationFolder, true);
                }

    How can I make it respect the folder which the user selected?  Thank you very much.

    Imported from legacy forums. Posted by Robert (had 3196 views)

    User (Old forums)
    Member
    Post count: 23064

    Can you tell me what extractionDirectory resolves to at runtime?

    Imported from legacy forums. Posted by André (had 2152 views)

    User (Old forums)
    Member
    Post count: 23064

    In my code it is set to c:\x, and this is what it uses at runtime regardless of what I enter in the dialog.  Does this help?

     

    Thanks

    Imported from legacy forums. Posted by Robert (had 209 views)

    User (Old forums)
    Member
    Post count: 23064

    The problem is that you are setting an absolute path to the ZippedFolder when you build the archive, whereas it should be a relative path.  The zip archive is created with this absolute path, which means all files copied to this folder will have the drive letter incorporated to their path, though you will not see it in WinZip when you inspect the file.  (You can test this by simply zipping two different ZippedFolder to same zip archive, one “C:\x”, the other “\x”, and zipping the same files in both cases, and you will see all files appear twice with the exact same path “\x”, which normally should not be, files should be overridden and only one copy should be found in the archive). 

    The result of this is that when the SFX binary extract the files form the archive, it reads the path of each file (an absolute path), and simply copies those files to that path, ignoring the DefaultDestinationFolder.  In the case of a relative path, it will simply add this relative path to the DefaultDestinationFolder (or to the absolute path provided by the user through the dialog), and unzip the files there.

    You should remove the drive letter part from “extractionDirectory” when creating the ZippedFolder instance (destinationFolder).

     

    Imported from legacy forums. Posted by André (had 2173 views)

    User (Old forums)
    Member
    Post count: 23064

    This solved the issue, thank you very much for your prompt assistance!

    Imported from legacy forums. Posted by Robert (had 3657 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.