User (Old forums)MemberMarch 25, 2009 at 11:35 amPost count: 23064
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);
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)MemberMarch 25, 2009 at 5:04 pmPost 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)MemberMarch 26, 2009 at 12:03 pmPost 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?
Imported from legacy forums. Posted by Robert (had 209 views)User (Old forums)MemberMarch 26, 2009 at 5:05 pmPost 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)
- You must be logged in to reply to this topic.