[
  {
    "Id": "240477",
    "ThreadId": "70602",
    "Html": "<p>Is it possible to build a self extracting archive that will silently unpack to the user's profile, run a specified executable from the archive and then tidy up once the operation is completed?</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-30T08:50:43.57-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "240546",
    "ThreadId": "70602",
    "Html": "<p>Self-extracting archives have a default extract location, but there is currently no &quot;variable substitution&quot; that would support &quot;the current user's profile&quot;.&nbsp;&nbsp; Sounds like a good feature to add though: do environment variable substitutions on the extract location.</p>\r\n<p>There is also a execute-on-extract setting, which you can use to run a specified executable.&nbsp; I don't know what you mean by &quot;tidy up&quot; but I suppose the executable that runs could do any tidying you need.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-30T10:36:14.777-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "240547",
    "ThreadId": "70602",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8893\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-09-30T10:37:06.18-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242439",
    "ThreadId": "70602",
    "Html": "<p>Hi,<br><br>This&nbsp;discussion has been moved to work item that I'm not sure addresses the main problem i am facing. If you've got a moment I'll describe in detail what I am trying to achieve. <br><br>I have an application which upgrades our main product's database. There are literally thousands of scripts used in the upgrade process. The application expects to find the scripts in a folder next to the exe.<br><br>I don't want to have to ship a zip file and get clients to unzip it somewhere then start the application. I would like to just ship an exe that unpacks the application and scripts somewhere (user profile?) then starts the application. Once the application has completed it would be nice if the unzipped files were deleted leaving just the self extracting archive.<br><br>Does this make sense? At the minute the two flavors of self exctracting archive don't quite achieve what i am after.</p>",
    "PostedDate": "2009-10-06T00:36:57.363-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242582",
    "ThreadId": "70602",
    "Html": "<p>OK, I think I understand what you wrote.</p>\r\n<p>Why does the self-extracting archive not achieve what you are after?&nbsp; Are you saying, you cannot easily run an application that was inside the SFX?&nbsp;&nbsp; I think you're right about that but I want to be sure.</p>\r\n<p>There is a &quot;run exe on extraction&quot; option.&nbsp; You are using the <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/2ded1502-2970-e092-bdc2-407c249f80b9.htmhttp://cheeso.members.winisp.net/DotNetZipHelp/html/2ded1502-2970-e092-bdc2-407c249f80b9.htm\">SaveSelfExtractor() method</a> that accepts a postExtractCommandToExecute argument, right?</p>\r\n<p>I looked in the code and found that the Command Line self-extractor sets the working directory to the extraction directory, before executing the &quot;post execute command&quot;.&nbsp; So you can execute an exe that was inside the zip.&nbsp; The WinForms self-extractor does not set the working directory, so you cannot easily execute a command that is inside the zip.&nbsp; This seems like a bug in the WinForms SFX, but I Want to be sure this is the problem you are facing.</p>",
    "PostedDate": "2009-10-06T08:24:49.343-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242591",
    "ThreadId": "70602",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>Thanks for responding. I have tried using the SaveSelfExtractor method using the Command Line flavor and it is almost what I'm after. The problems being</p>\r\n<ol>\r\n<li>there is a command prompt window hanging around that looks a bit weird</li>\r\n<li>the files are unzipped to the location of the self extracting archive, if this was the desktop it would be a bit of a mess with my thousand odd scripts! it would be good if you could specify user profile or temp folder.</li>\r\n<li>once the main application has completed i would like the stub to tidy up all the files it has unzipped so that just the sfx remains.</li>\r\n</ol>\r\n<p>Happy to help in whatever way i can, but i'm more of a vb/sql guy than c# unfortunately.</p>\r\n<p>Cheers,</p>\r\n<p>Ste</p>",
    "PostedDate": "2009-10-06T08:48:46.973-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242615",
    "ThreadId": "70602",
    "Html": "<p>Hm, ok.</p>\r\n<ol>\r\n<li>I guess you are starting the exe by double-click?&nbsp; The CMD window won't be there if you use the WinForms GUI SFX, once I get that bug fixed (the one I mentioned above about setting the working directory).&nbsp; This will be in just a few minutes.</li>\r\n<li>The files can be unzipped to a specific directory - with either the command line SFX or the Winforms GUI SFX.&nbsp; In the command line version you need to pass an argument to the exe to specify which directory to extract to.&nbsp; Obviously you can't do this, if the way you run the sfx exe is to double-click it in Explorer.&nbsp; in the WinForms SFX you specify the extract directory with a textbox. </li>\r\n<li>You want dotnetzip to delete all the files it has unpacked, after the &quot;post extract exe&quot; completes.&nbsp;&nbsp; Is that right?&nbsp; &nbsp;I'll have to look into this.&nbsp; <br>My original thought was, that doesn't seem&nbsp;the right way to do things.&nbsp; Why should a &quot;Self extractor&quot; delete the files it extracted?&nbsp;&nbsp; Seems to me the &quot;post extract exe&quot; - your exe - should be responsible for that kind of thing.&nbsp;&nbsp;But I can see the utility in having the SFX do the cleanup.&nbsp;&nbsp;And it wouldn't be that hard to add to DotNetZip. &nbsp;I have to think about this a little more.&nbsp; </li>\r\n</ol>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-06T09:56:35.343-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242619",
    "ThreadId": "70602",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8925\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-10-06T10:03:12.55-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242641",
    "ThreadId": "70602",
    "Html": "<p>Hi,</p>\r\n<p>Here's a little extra background to&nbsp;explain the reasoning behind my ideas</p>\r\n<p>I have written an application to upgrade our clients database. The finished app consists of an exe, a few dlls and&nbsp;a few hundred&nbsp;scripts. The scripts are built as part of a seperate process and so will be different from build to build, the exe and dlls are expected to remain static.</p>\r\n<p>I need to ship the lot to our clients in a format that gives them the minimum opportunity to get things wrong! I could zip the lot up and tell them to extract it somewhere then run the exe - but this will undoubtably be too hard for some of them (really!!) What i would like to ship is one file that you double click and it opens the application with the files ready to go. I suppose i could somehow add the scripts as resources and embed them into the exe somehow, but what about the dlls? Another option would be to use an msi file, but we aren't really installing anything on the machine in terms of a client app so this seems wrong - plus I hate&nbsp;trying to build msi files!</p>\r\n<p>What I'm after is one file, an exe that users can just double click and my application starts up - as if it was the exe they just clicked on. Once the application has finished the self extracting stub tidies up the files it unipped so to the users eyes the unzipping is invisible - they just ran a plain old exe.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-06T10:58:10.863-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242690",
    "ThreadId": "70602",
    "Html": "<p>That's helpful.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-06T12:53:27.87-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242786",
    "ThreadId": "70602",
    "Html": "<table border=0 width=800>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<p>ok, I just posted v1.9.0.15 that includes changes for you.</p>\r\n<p>The programming model for SaveSelfExtractor has changed to support the extra stuff you asked for, including removing of files after the post-extract command executes.&nbsp; Here's an example:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>    <span style=\"color:Green\">// create the SFX</span>\r\n    <span style=\"color:Blue\">using</span> (ZipFile zip1 = <span style=\"color:Blue\">new</span> ZipFile())\r\n    {\r\n        zip1.AddFiles(files, <span style=\"color:#A31515\">&quot;&quot;</span>);\r\n        zip1.AddFile(postExtractExe, <span style=\"color:#A31515\">&quot;&quot;</span>);\r\n        zip1.Comment = <span style=\"color:#A31515\">&quot;This will be embedded into a self-extracting exe&quot;</span>;\r\n        zip1.AddEntry(<span style=\"color:#A31515\">&quot;Readme.txt&quot;</span>, <span style=\"color:#A31515\">&quot;This is the content for the readme file...&quot;</span>);\r\n        SelfExtractorSaveOptions sfxOptions = <span style=\"color:Blue\">new</span> SelfExtractorSaveOptions();\r\n        sfxOptions.Flavor = SelfExtractorFlavor.ConsoleApplication;\r\n        sfxOptions.Quiet = <span style=\"color:Blue\">true</span>; <span style=\"color:Green\">// hides the window after startup</span>\r\n        sfxOptions.DefaultExtractDirectory = <span style=\"color:#A31515\">&quot;%USERPROFILE%\\\\AppData\\\\Local\\\\Temp\\\\patch1&quot;</span>;\r\n        sfxOptions.PostExtractCommandLine= postExtractExe;\r\n        sfxOptions.RemoveUnpackedFilesAfterExecute = <span style=\"color:Blue\">true</span>; \r\n        zip1.SaveSelfExtractor(SfxFileToCreate, sfxOptions);\r\n    }\r\n\r\n</pre>\r\n</div>\r\n<p>I learned that there's no way to make an EXE that can sometimes emit messages to the console, and sometimes not. So, the ConsoleApplication SFX, when you double-click it in explorer or as an attachment, will hide the window that Windows gives it, if the Quiet flag is set. You see the window appear and then it disappears.&nbsp; If you run the ConsoleApplication SFX from the cmd.exe prompt, it runs as a normal console app, and displays messages to the console.</p>\r\n<p>If you don't set the <strong>Quiet</strong> flag, then when double-clicking to launch the SFX, the window will remain, and the SFX will emit a message for each file as it extracts. The messages fly by so quickly, they won't be easily readable.&nbsp; But now you have a choice - either a window that pops up and disappears, or a window that stays up and displays messages. I think either is preferable to a empty window that never displays anything, which is what it was before.&nbsp;</p>\r\n<p>You also now have environment variable expansion.&nbsp; The syntax is like&nbsp;%USERPROFILE%, and the env vars get expanded when the SFX is run.&nbsp; You can use them in either the DefaultExtractDirectory or in the PostExtractCommandLine.&nbsp; If the env var is unknown at runtime, the string remains - it does not evaluate to (blank).&nbsp;</p>\r\n<p>RemoveUnpackedFilesAfterExecute works only if you have a non-empty PostExtractCommandLine.&nbsp; It causes the SFX to wait until the command specified in PostExtractCommandLine completes, and then removes all the unpacked files. Then the SFX exits.&nbsp; If the PostExtractCommandLine returns a non-zero status code, that is taken as a failure, and the SFX does not remove the unpacked files in that case.&nbsp;</p>\r\n<p>This is all documented in the CHM file.</p>\r\n<p>Let me know if this works for you.</p>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>",
    "PostedDate": "2009-10-06T20:59:45.143-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "242843",
    "ThreadId": "70602",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>That's great, thanks! I've had another idea if you have the time...</p>\r\n<p>Rather than have a console app stub which flicks up a command window, would it be possible to just have a progress bar showing&nbsp;the unzip progress and maye some text along the lines of &quot;Preparing application...&quot;? The unzip process could take a while given the large amount of files, so a progress bar would stop the users opening the sfx again (...and again, and again!!)</p>\r\n<p>Appreciate your time on this.</p>",
    "PostedDate": "2009-10-07T01:13:10.867-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "243014",
    "ThreadId": "70602",
    "Html": "<p>Hey Ste, that isn't what you asked for last time!</p>\r\n<p>Ok, I posted v1.9.0.16.&nbsp; If you set the Quiet flag and use a WinForms flavor, then it will show a progress bar as it runs, which I think is what you described.&nbsp; You also may want to set the PostExtractCommandLine and RemoveUnpackedFilesAfterExecute.</p>\r\n<p>Try it and let me know.</p>",
    "PostedDate": "2009-10-07T09:20:21.143-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "243207",
    "ThreadId": "70602",
    "Html": "<p>Hey, I'd love a copy of this build.&nbsp; Where do I go to download it?</p>\r\n<p>&nbsp;</p>\r\n<p>thanks,</p>\r\n<p>&nbsp;</p>\r\n<p>David</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-07T17:59:17.687-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "243208",
    "ThreadId": "70602",
    "Html": "<p>Sorry, posting a spam so I can check the box to get an email when you reply.</p>",
    "PostedDate": "2009-10-07T18:00:04.333-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "243277",
    "ThreadId": "70602",
    "Html": "<p>on <a href=\"http://dotnetzip.codeplex.com/Release/ProjectReleases.aspx\">http://dotnetzip.codeplex.com/Release/ProjectReleases.aspx</a></p>\r\n<p>The default release is v1.8.&nbsp; You don't want that.&nbsp; You want the v1.9 release.&nbsp; Look in the far-right side, near the top, you'll see a box with release options.</p>\r\n<p><img src=\"http://i33.tinypic.com/29z8rah.jpg\" alt=\"\"></p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-07T23:37:59.213-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245587",
    "ThreadId": "70602",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>Sorry for the delay in responding on this, I've had other more mundane tasks to attend to :o(</p>\r\n<p>Anyhoo I have decided to write my own self extracting stub rather than keep pestering you for minor changes and i am nearly done :o)&nbsp;My only problem is creating the SFX. I write out my EXE to a stream and append the zip file using the following code but I end up with a corrupt archive. Could you point me in the right direction? Many thanks, ste</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">\tUsing</span> zp <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> ZipFile\r\n            zp.AddFiles(Directory.GetFiles(<span style=\"color:#A31515\">&quot;P:\\PS ProSolution\\System\\Devel\\Setup\\New Installer\\Patch\\Wizard&quot;</span>), <span style=\"color:Blue\">False</span>, <span style=\"color:#A31515\">&quot;&quot;</span>)\r\n\r\n            <span style=\"color:Blue\">Dim</span> asm <span style=\"color:Blue\">As</span> Reflection.<span style=\"color:Blue\">Assembly</span> = Reflection.<span style=\"color:Blue\">Assembly</span>.GetAssembly(<span style=\"color:Blue\">GetType</span>(SFXStub.Form1))\r\n            <span style=\"color:Blue\">Dim</span> output <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> FileStream(<span style=\"color:#A31515\">&quot;C:\\steeee.exe&quot;</span>, FileMode.Create)\r\n\r\n            <span style=\"color:Blue\">Using</span> input <span style=\"color:Blue\">As</span> System.IO.Stream = asm.GetFiles()(0)\r\n                <span style=\"color:Blue\">Dim</span> buffer <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Byte</span>() = <span style=\"color:Blue\">New</span> <span style=\"color:Blue\">Byte</span>(3999) {}\r\n                <span style=\"color:Blue\">Dim</span> n <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span> = 1\r\n                <span style=\"color:Blue\">While</span> n &lt;&gt; 0\r\n                    n = input.Read(buffer, 0, buffer.Length)\r\n                    <span style=\"color:Blue\">If</span> n &lt;&gt; 0 <span style=\"color:Blue\">Then</span>\r\n                        output.Write(buffer, 0, n)\r\n                    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n                <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">While</span>\r\n            <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n\r\n            zp.Save(<span style=\"color:#A31515\">&quot;c:\\test.zip&quot;</span>)\r\n\r\n            <span style=\"color:Blue\">Using</span> input <span style=\"color:Blue\">As</span> System.IO.Stream = <span style=\"color:Blue\">New</span> FileStream(<span style=\"color:#A31515\">&quot;c:\\test.zip&quot;</span>, FileMode.Open)\r\n                <span style=\"color:Blue\">Dim</span> buffer <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Byte</span>() = <span style=\"color:Blue\">New</span> <span style=\"color:Blue\">Byte</span>(3999) {}\r\n                <span style=\"color:Blue\">Dim</span> n <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span> = 1\r\n                <span style=\"color:Blue\">While</span> n &lt;&gt; 0\r\n                    n = input.Read(buffer, 0, buffer.Length)\r\n                    <span style=\"color:Blue\">If</span> n &lt;&gt; 0 <span style=\"color:Blue\">Then</span>\r\n                        output.Write(buffer, 0, n)\r\n                    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n                <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">While</span>\r\n            <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n\r\n            output.Close()\r\n\r\n            <span style=\"color:Green\">'My.Application.Info.LoadedAssemblies</span>\r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n</pre>\r\n</div>",
    "PostedDate": "2009-10-14T07:21:52.197-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245696",
    "ThreadId": "70602",
    "Html": "<p>Writing your own extractor stub - well good for you.&nbsp; Sounds like a good project.</p>\r\n<p>In my opinion there are two ways to go, if you want a self-extracting archive.&nbsp; First is to embed the zip as an &quot;embedded resource&quot;.&nbsp; The second is to append the zip content after the EXE &quot;stub&quot; content.&nbsp;</p>\r\n<p>If you go the first route, you can just read the zip from the resource Stream that you get from Assembly.GetManifestResourceStream().&nbsp; This works just fine.&nbsp; The resulting exe file is not readable as a regular zip file though.&nbsp; You cannot examine it in WinZip, or using DotNetZip.&nbsp; The file is an EXE file, with an embedded zip file.</p>\r\n<p>With option 2, the generated EXE will be both a zip and an EXE.&nbsp; There's just one tricky part: you have to take care to deal with the issue of offsets. Within the zip file there are offsets that refer to points in the zip stream where entries are found.&nbsp; Let's suppose you have a zipfile of 1000 bytes.&nbsp; The zip directory falls at the end of the file, say, the last 100 bytes.&nbsp; In there are values that point to positions in the prior 900 bytes, at which zip entry data is found.&nbsp; An offset of 0 for entry #0 in that directory will refer to the first byte in the zip stream, byte 0 of 1000.&nbsp; An offset of 100 for entry #1 will refer to byte 100 of 1000.</p>\r\n<p>Now suppose you append that zip file, with the offsets unchanged onto an exe stub.&nbsp; Suppose the exe stub is 10,000 bytes long.&nbsp; The total file size is thus 11,000 bytes - 10,000 for the exe stub, and 1000 for the appended zip content.&nbsp; An offset of 0 in the zip directory, which previously&nbsp;refered to byte 0 of 1000, now refers to byte 0 of 11,000 in the file.&nbsp; If you try to read a zip entry at byte 0, you will get rubbish.&nbsp; You will be trying to read a zipentry where the PE-COFF (EXE) header is found .&nbsp; That won't work.</p>\r\n<p>This is what you are seeing.&nbsp; you are appending a zip datastream without modification to the end of your stubexe content.</p>\r\n<p>So you need to adjust the offsets.</p>\r\n<p>One way to do it would be to adjust every offset in the zip datastream, after it has been written, to refer to&nbsp;the adjusted position in the file.&nbsp; An offset of 0 must change to an offset of 10,000.&nbsp; An offset of 100 must change to an offset of 10,100.&nbsp; And so on.&nbsp; You would need to modify each offset in the stream.&nbsp; This is tedious and requires re-parsing the generated zip datastream.&nbsp; I don't recommend it.</p>\r\n<p>There's another way - DotNetZip is smart enough when writing zip content out to a stream to use the Stream.Position value to determine the offset.&nbsp; So, when generating the SFX, if you do this:</p>\r\n<ul>\r\n<li>create and open&nbsp;a stream</li>\r\n<li>write the sfx stub out to the stream</li>\r\n<li>write the zip content out&nbsp;to the same stream</li>\r\n<li>close that single stream</li>\r\n</ul>\r\n<p>...then the offsets in the zip content will be correct.</p>\r\n<p>in code, you would need to replace this code in your example:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>            zp.Save(<span style=\"color:#A31515\">&quot;c:\\test.zip&quot;</span>)\r\n\r\n            <span style=\"color:Blue\">Using</span> input <span style=\"color:Blue\">As</span> System.IO.Stream = <span style=\"color:Blue\">New</span> FileStream(<span style=\"color:#A31515\">&quot;c:\\test.zip&quot;</span>, FileMode.Open)\r\n                <span style=\"color:Blue\">Dim</span> buffer <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Byte</span>() = <span style=\"color:Blue\">New</span> <span style=\"color:Blue\">Byte</span>(3999) {}\r\n                <span style=\"color:Blue\">Dim</span> n <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span> = 1\r\n                <span style=\"color:Blue\">While</span> n &lt;&gt; 0\r\n                    n = input.Read(buffer, 0, buffer.Length)\r\n                    <span style=\"color:Blue\">If</span> n &lt;&gt; 0 <span style=\"color:Blue\">Then</span>\r\n                        output.Write(buffer, 0, n)\r\n                    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n                <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">While</span>\r\n            <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n\r\n            output.Close()</pre>\r\n</div>\r\n<p>with the much simpler</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>     zp.Save(output)\r\n\r\n</pre>\r\n</div>\r\n<p>it looks like this:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>    <span style=\"color:Blue\">Using</span> zp <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> ZipFile\r\n        zp.AddFiles(Directory.GetFiles(<span style=\"color:#A31515\">&quot;P:\\PS ProSolution\\System\\Devel\\Setup\\New Installer\\Patch\\Wizard&quot;</span>), <span style=\"color:Blue\">False</span>, <span style=\"color:#A31515\">&quot;&quot;</span>)\r\n\r\n        <span style=\"color:Blue\">Dim</span> asm <span style=\"color:Blue\">As</span> Reflection.<span style=\"color:Blue\">Assembly</span> = Reflection.<span style=\"color:Blue\">Assembly</span>.GetAssembly(<span style=\"color:Blue\">GetType</span>(SFXStub.Form1))\r\n        <span style=\"color:Blue\">Using</span> output <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">As</span> System.IO.Stream = <span style=\"color:Blue\">New</span> FileStream(<span style=\"color:#A31515\">&quot;C:\\steeee.exe&quot;</span>, FileMode.Create)\r\n\r\n            <span style=\"color:Blue\">Using</span> input <span style=\"color:Blue\">As</span> System.IO.Stream = asm.GetFiles()(0)\r\n                <span style=\"color:Blue\">Dim</span> buffer <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Byte</span>() = <span style=\"color:Blue\">New</span> <span style=\"color:Blue\">Byte</span>(3999) {}\r\n                <span style=\"color:Blue\">Dim</span> n <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span> = 1\r\n                <span style=\"color:Blue\">While</span> n &lt;&gt; 0\r\n                    n = input.Read(buffer, 0, buffer.Length)\r\n                    <span style=\"color:Blue\">If</span> n &lt;&gt; 0 <span style=\"color:Blue\">Then</span>\r\n                        output.Write(buffer, 0, n)\r\n                    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n                <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">While</span>\r\n            <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n\r\n            zp.Save(output)\r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n\r\n    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n</pre>\r\n</div>\r\n<p>(You should be using a Using clause for the output stream.)&nbsp;&nbsp; Then, for extraction, the EXE in outputFile (in your stub) must do a ZipFile.Read() using <em>itself </em>as the input.&nbsp;&nbsp; It must read the file location of the currently executing EXE.</p>\r\n<p>Something like this:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>Assembly a = Assembly.GetExecutingAssembly();\r\n<span style=\"color:Blue\">try</span>\r\n{\r\n    <span style=\"color:Blue\">using</span> (ZipFile zip = ZipFile.Read(a.Location))\r\n    {\r\n        <span style=\"color:Blue\">foreach</span> (ZipEntry entry <span style=\"color:Blue\">in</span> zip)\r\n        {\r\n            <span style=\"color:Green\">// handle each entry here</span>\r\n        }\r\n    }\r\n}\r\n...\r\n</pre>\r\n</div>\r\n<p>I know you're a VB guy, but I figure you can see what's going on there.&nbsp;</p>\r\n<p>Also I can see you're no stranger to Reflector. Generate an SFX with DotNetZip in the traditional way and then examine the result in Reflector to see what I mean.</p>\r\n<p>I don't know exactly what you're doing with <span style=\"color:Blue\">Using</span> input <span style=\"color:Blue\">As</span> System.IO.Stream = asm.GetFiles()(0)<br>I think that gets the first file in the list of files for the given assembly.&nbsp; If that just opens the stub exe, then it seems right to me.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-14T11:19:47.72-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245812",
    "ThreadId": "70602",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>That's great, it's quite difficult to find this info anywhere on the internet.</p>\r\n<p>However, I initially tried the method you mention above and something goes wrong as i end up with an exe that is seen as a console app and runs with error &quot;Program too big to fit in memory&quot;. It behaves well as a zip but not an exe, any ideas.</p>\r\n<p>Really appreciate your&nbsp;help on this.</p>\r\n<p>Ste</p>",
    "PostedDate": "2009-10-14T16:24:46.207-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245827",
    "ThreadId": "70602",
    "Html": "<p>&gt; an exe that is seen as a console app</p>\r\n<p>Hmm, I don't know what that means. If I were you, to troubleshoot it I would produce a super small basic EXE, just a basic form with a &quot;Close&quot; button.&nbsp;&nbsp;(It shouldn't try to do anything with the&nbsp;appended zip file).&nbsp; &nbsp;Then, in a separate app, run the code above which saves the EXE and the zip file to the same stream.&nbsp; The result should be able to run as an EXE, which still just shows a &quot;Close&quot; button.&nbsp; It should also be readable as a&nbsp;zip file in any tool.</p>\r\n<p>If that works, then you can add one piece at a time to the app, iteratively, until you get it working the way you want.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-14T17:44:05.81-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245862",
    "ThreadId": "70602",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8985\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-10-14T21:16:09.47-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245865",
    "ThreadId": "70602",
    "Html": "<p>Ste,</p>\r\n<p>I took my the advice I gave you, and built an app like I described.&nbsp; Surprise!&nbsp;&nbsp;I found that it didn't work.&nbsp; Turns out I was wrong when I wrote &quot;DotNetZip is smart enough when writing zip content out to a stream to use the Stream.Position value to determine the offset.&quot;&nbsp;&nbsp; It was <em>almost </em>doing that properly.&nbsp;&nbsp; I had to modify the library to make it do the right thing.</p>\r\n<p>Now that I fixed the library, it's working.&nbsp; Here's how I did it.&nbsp; You've got a winforms app, a &quot;stub&quot; self extractor, right?&nbsp; And as I told you, creating the actual SFX is not just a matter of simple concatenation of the bytestreams.&nbsp; You need some simple logic to create the SFX.&nbsp; Here is what I used:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>&lt;STAThread&gt; _\r\n<span style=\"color:Blue\">Public</span> <span style=\"color:Blue\">Shared</span> <span style=\"color:Blue\">Function</span> Main(<span style=\"color:Blue\">ByVal</span> args <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span>()) <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span>\r\n    <span style=\"color:Blue\">Dim</span> outputFile <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span> = <span style=\"color:#A31515\">&quot;stee-sfx.exe&quot;</span>\r\n    <span style=\"color:Blue\">Dim</span> sfxStub <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span> = <span style=\"color:#A31515\">&quot;Stee.exe&quot;</span>\r\n    <span style=\"color:Blue\">Dim</span> directoryToZip <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span> = <span style=\"color:#A31515\">&quot;c:\\directory\\to\\ZIP&quot;</span>\r\n    <span style=\"color:Blue\">Dim</span> buffer <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Byte</span>() = <span style=\"color:Blue\">New</span> <span style=\"color:Blue\">Byte</span>(4000){}\r\n    <span style=\"color:Blue\">Dim</span> n <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span> = 1\r\n    <span style=\"color:Blue\">Using</span> output <span style=\"color:Blue\">As</span> System.IO.Stream = File.Open(outputFile, FileMode.Create)\r\n        <span style=\"color:Blue\">Using</span> zp <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> ZipFile\r\n            zp.AddFiles(Directory.GetFiles(directoryToZip), <span style=\"color:Blue\">False</span>, <span style=\"color:#A31515\">&quot;&quot;</span>)\r\n            <span style=\"color:Blue\">Using</span> input <span style=\"color:Blue\">As</span> System.IO.Stream = File.Open(sfxStub, FileMode.Open)\r\n                <span style=\"color:Blue\">While</span> n &lt;&gt; 0\r\n                    n = input.Read(buffer, 0, buffer.Length)\r\n                    <span style=\"color:Blue\">If</span> n &lt;&gt; 0 <span style=\"color:Blue\">Then</span>\r\n                        output.Write(buffer, 0, n)\r\n                    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n                <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">While</span>\r\n            <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n            zp.Save(output)\r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n<span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Function</span></pre>\r\n</div>\r\n<p>Ok, then in the SFX stub application, you need to have the application read <em>itself</em>.&nbsp; Here's what I used: &nbsp;</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">Private</span> <span style=\"color:Blue\">Sub</span> Form_Shown(<span style=\"color:Blue\">ByVal</span> sender <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Object</span>, <span style=\"color:Blue\">ByVal</span> e <span style=\"color:Blue\">As</span> EventArgs)\r\n    <span style=\"color:Blue\">Dim</span> a <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Assembly</span> = <span style=\"color:Blue\">Assembly</span>.GetExecutingAssembly\r\n    <span style=\"color:Blue\">Try</span>\r\n        <span style=\"color:Blue\">Using</span> zp <span style=\"color:Blue\">As</span> ZipFile = ZipFile.Read(a.Location)\r\n            <span style=\"color:Blue\">Dim</span> entry <span style=\"color:Blue\">As</span> ZipEntry\r\n            <span style=\"color:Blue\">For</span> <span style=\"color:Blue\">Each</span> entry <span style=\"color:Blue\">in</span> zp\r\n                listBox1.Items.Add(entry.FileName)\r\n            <span style=\"color:Blue\">Next</span>\r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n    <span style=\"color:Blue\">Catch</span>\r\n        listBox1.Items.Add(<span style=\"color:#A31515\">&quot;-No embedded zip file.-&quot;</span>)\r\n    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Try</span>\r\n<span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Sub</span></pre>\r\n</div>\r\n<p>This is part of a simple WinForms app. That method is attached to the &quot;Shown&quot; event on the form. It reads the EXE that is currently executing, and then displays the zip entries in the listbox on the form. &nbsp;You'd have to modify that logic to do something more interesting, like extract, but the basic bones are there.</p>\r\n<p>To do this you need the change I made in the library.&nbsp; It is available in v1.9.0.21.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-14T21:32:00.317-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245918",
    "ThreadId": "70602",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>your self extractor is amazing, thank you for your knowledge.</p>\r\n<p>I have to make a self extracting file that execute a exe inside when extracting, I did it thanks to you :)</p>\r\n<p>I just have a problem with the ConsoleApplication, I use it to provide transparency&nbsp;to the clients, they just have to double click to the exe file and everything is done...the first time it works, BUT if the client want to re-run exe, it won't overwrite the existing files and unfortunately won't execute the exe inside.</p>\r\n<p>I thought to RemoveUnpackedFilesAfterExecute=true but if client cancel/close the execution of the exe file, the RemoveUnpackedFilesAfterExecute will not be executed.</p>\r\n<p>I know that I just have to pass the &quot;-o&quot; parameter to the exe but client will not do this (they don't know, they just won't to click in exe).</p>\r\n<p>I just want to overwrite the existing files using ConsoleApplication by double clicking the exe file...</p>\r\n<p>Can you help me to handle this? Thank you !!</p>\r\n<p>Kinf Regards</p>",
    "PostedDate": "2009-10-15T00:53:02.01-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245957",
    "ThreadId": "70602",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8987\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-10-15T03:46:37.517-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245962",
    "ThreadId": "70602",
    "Html": "<p>Hey Fred, I liked your idea so I created a new workitem for it, and implemented something that should satisfy you.</p>\r\n<p>There's a new option called ExtractExistingFile.&nbsp; Set it to the thing you want, to default the behavior of the generated SFX.&nbsp;</p>\r\n<p>You need v1.9.0.23 to get this feature.</p>",
    "PostedDate": "2009-10-15T04:00:04.713-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245971",
    "ThreadId": "70602",
    "Html": "<p>Great!</p>\r\n<p>I saw the same option for zip behavior but include it for self extract file is a very good idea.</p>\r\n<p>Well done !!</p>\r\n<p>&nbsp;</p>\r\n<p>By the way, i've found something strange. PostExtractCommandLine doen't like name with blank..(Hello world.exe will not work, but HelloWorld.exe =&gt;ok).&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>kind Rgs</p>\r\n<p>Fred.</p>\r\n<pre style=\"font-size:1em;font-family:Consolas, 'Courier New', Courier, monospace\"><span style=\"font-family:'Segoe UI', 'Microsoft Sans Serif', Arial, Geneva, sans-serif\"><span style=\"white-space:normal\"><span style=\"font-family:Consolas, 'Courier New', Courier, monospace\"><span style=\"white-space:pre\"><br></span></span></span></span></pre>",
    "PostedDate": "2009-10-15T04:32:54.923-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245984",
    "ThreadId": "70602",
    "Html": "<p>Hey Fred, thanks for the feedback.</p>\r\n<p>On the commandline:&nbsp; the way it works is this:&nbsp; If there is no whitespace in the commandline argument, the argument is treated as the name of a program, and that program is run.&nbsp; If there is some whitespace in the commandline argument, the arg is split.&nbsp; The first part is treated as the filename of the program, and the&nbsp;remainder is the set of arguments to the program.&nbsp; If you have a program name (or path) that includes a space, it will break this logic.</p>\r\n<p>I'll get that fixed, too.&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-15T05:08:02.837-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "245985",
    "ThreadId": "70602",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8988\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-10-15T05:08:48.61-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "246092",
    "ThreadId": "70602",
    "Html": "<p>Hey Cheeso,</p>\r\n<p>You are a star!&nbsp;My upgrade self extracting exe is working perfectly.</p>\r\n<p>Thank you,</p>\r\n<p>Ste</p>",
    "PostedDate": "2009-10-15T08:40:20.917-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "246096",
    "ThreadId": "70602",
    "Html": "<p>Glad to hear it, Ste!</p>",
    "PostedDate": "2009-10-15T08:50:10.22-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "246104",
    "ThreadId": "70602",
    "Html": "<p>Fred --</p>\r\n<p>Spaces in the commandline program are now supported.&nbsp; If the program filename or path has spaces, you need to surround the command with double-quotes, just as you would at a command prompt.</p>\r\n<p>Get v1.9.0.24 for this fix.</p>\r\n<p>-Cheeso</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-15T09:05:45.023-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247213",
    "ThreadId": "70602",
    "Html": "<p>Hello Cheeso,</p>\r\n<p>Thanks for your support, it help me a lot !</p>\r\n<p>As I said you, i'm creating a multiple selfextracting file generator using a xml in input (with several directories to zip).</p>\r\n<p>Everything worked well (browse, etc)&nbsp;but now strange behaviour...when I browse a xml file and do the call 'SaveSelfExtractor', I have a exception &quot;Errors compiling the extraction logic! &nbsp;C:\\Documents and Settings\\fdv\\Local Settings\\Temp\\Ionic.Zip-2009oct.19-111744-1.cs&quot;. I'm using XP Pro..</p>\r\n<p>Can you explain me why I have this suddenly ?</p>\r\n<p>Hope there is solution...</p>\r\n<p>Kind Regards.</p>\r\n<p>Fred.</p>",
    "PostedDate": "2009-10-19T02:22:06.433-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247222",
    "ThreadId": "70602",
    "Html": "<p>Re,</p>\r\n<p>I've checked for the openFileDialog who caused the exception, and after changing to a FolderBrowserDialog, it works.</p>\r\n<p>Why it doesn't work with a openFileDialog ? I don't understand...really.</p>\r\n<p>Let me know.</p>\r\n<p>Fred.</p>",
    "PostedDate": "2009-10-19T02:49:16.93-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247253",
    "ThreadId": "70602",
    "Html": "<p>Hello,</p>\r\n<p>After investigation I've found the problem !</p>\r\n<p>I don't know why, after removing my personal .ico for self extracting files everything works fine.</p>\r\n<p>So, I will use the default icon.</p>\r\n<p>^^</p>",
    "PostedDate": "2009-10-19T05:54:04.48-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247396",
    "ThreadId": "70602",
    "Html": "<p>Fred, if you send me the contents of that .cs file, I may be able to help explain the error you get when producing an SFX with a custom .ico file.&nbsp; You can also look for yourself - if you use the latest version of DotNetZip (either v1.8 or v1.9), then the compilation errors will be documented at the bottom of that source file.</p>\r\n<p>I have no idea what you are talking about with the openFileDialog vs FolderBrowserDialog.&nbsp; Can you explain what that relates to?</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-19T11:56:07.59-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247592",
    "ThreadId": "70602",
    "Html": "<p>Cheeso,</p>\r\n<p>I will try to explain.</p>\r\n<p>What : I get this error message &quot;Problem occurs while creating files : Errors compiling the extraction logic ! c:\\..\\Ionic.Zip***.cs&quot;</p>\r\n<p>When : - when I want to add my self icon for the self Extracting file (not a problem I've restored the default icon)</p>\r\n<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - When I publish my project, and install it to a another machine (like server 2003). I run my program and get this message too (using default icon)..</p>\r\n<p>Can you explain what is this error exactly ? what triggers it ?&nbsp;&nbsp;And why this behavior when I run the exe in another OS, is there something missing? something that I have to add in addition to the dll ? Or server 2003 have to have the 3.5 SP1 framework installed ?</p>\r\n<p>&nbsp;</p>\r\n<p>Let me know.</p>\r\n<p>Fred.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-20T01:23:23.977-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247601",
    "ThreadId": "70602",
    "Html": "<p>sorry,</p>\r\n<p>I have this error when I let the default Icon&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">// ------------------------------------------------------------------</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">// Errors during compilation:&nbsp;</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">//</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">// &nbsp; Ionic.Zip-2009Oct20-103635-1.cs(0,0): error CVT1105: cannot seek in file</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">//</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">// &nbsp; Ionic.Zip-2009Oct20-103635-1.cs(0,0): error CS1583: 'c:\\Documents and Settings\\admin\\Local Settings\\Temp\\CSCB6.tmp' is not a valid Win32 resource file</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">//</div>\r\n<p>\r\n<p>// ------------------------------------------------------------------</p>\r\n<p>// Errors during compilation:&nbsp;</p>\r\n<p>//</p>\r\n<p>// &nbsp; Ionic.Zip-2009Oct20-103635-1.cs(0,0): error CVT1105: cannot seek in file</p>\r\n<p>//</p>\r\n<p>// &nbsp; Ionic.Zip-2009Oct20-103635-1.cs(0,0): error CS1583: 'c:\\Documents and Settings\\admin\\Local Settings\\Temp\\CSCB6.tmp' is not a valid Win32 resource file</p>\r\n<p>//</p>\r\n<p>Fred.</p>\r\n<p>&nbsp;</p>\r\n</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-20T01:41:40.01-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247626",
    "ThreadId": "70602",
    "Html": "<p>Ok,</p>\r\n<p>I can explain the bug and I will try to be clear...</p>\r\n<p>&nbsp;</p>\r\n<p>I have 2 browse, one for my xml input (tbXmlName) and one for the SFXfile directory output (tbDirName).</p>\r\n<p>I don't know why but when I browse to my xml file (i.e:&nbsp;<strong>C:\\Documents and Settings\\fdv\\Desktop\\vdb\\</strong>alldevices.xml) which content my SFXFilename (_fileTitle) and specify these options :</p>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SelfExtractorSaveOptions sfxOptions = new SelfExtractorSaveOptions();</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sfxOptions.Flavor = SelfExtractorFlavor.ConsoleApplication;</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sfxOptions.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sfxOptions.IconFile = &quot;client_vandenborre.ico&quot;;</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sfxOptions.Quiet = true; // hides the window after startup</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sfxOptions.DefaultExtractDirectory = &quot;%SystemRoot%\\\\&quot;;</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!File.Exists(_zipRoot + &quot;\\\\vaste_gegevens_rechts\\\\&quot; + _fileLanguage + &quot;\\\\vandenborre_screensaver\\\\install\\\\screensaverTemplate.exe&quot;))</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;throw new Exception(&quot;vandenborre_screensaver\\\\install\\\\screensaverTemplate.exe not found. Please check the file name.&quot;);</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sfxOptions.PostExtractCommandLine = &quot;vandenborre_screensaver\\\\install\\\\screensaverTemplate.exe&quot;;</div>\r\n<div id=\"_mcePaste\" style=\"left:-10000px;top:0px;width:1px;height:1px;overflow-x:hidden;overflow-y:hidden\">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;zip1.SaveSelfExtractor(tbDirName.Text + &quot;\\\\&quot; + _fileTitle + &quot;.exe&quot;, sfxOptions);</div>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>SelfExtractorSaveOptions sfxOptions = <span style=\"color:Blue\">new</span> SelfExtractorSaveOptions();\r\n\r\nsfxOptions.Flavor = SelfExtractorFlavor.ConsoleApplication;\r\n\r\nsfxOptions.ExtractExistingFile = ExtractExistingFileAction.OverwriteSilently;\r\n\r\nsfxOptions.IconFile = <span style=\"color:#A31515\">&quot;client_vdb.ico&quot;</span>;\r\n\r\nsfxOptions.Quiet = <span style=\"color:Blue\">true</span>; <span style=\"color:Green\">// hides the window after startup</span>\r\n\r\nsfxOptions.DefaultExtractDirectory = &quot;%SystemRoot%\\\\&quot;;\r\n\r\nzip1.SaveSelfExtractor(tbDirName.Text + <span style=\"color:#A31515\">&quot;\\\\&quot; + _fileTitle + &quot;</span>.exe&quot;, sfxOptions);\r\n</pre>\r\n</div>\r\n<p>I have this error :&nbsp;</p>\r\n<p>Ionic.Zip-2009oct.20-114925-1.cs(0,0): error CS1567: Error generating Win32 resource: Error reading icon '<strong>c:\\Documents and Settings\\fdv\\Desktop\\vdb\\</strong>client_vdb.ico' -- The system cannot find the file specified.&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>...seems like the icon link was affected by the browse..</p>\r\n<p>=&gt; If I don't browse when I execute my program, client_vdb.ico is found in the&nbsp;client_vdb.ico.deploy</p>\r\n<p>&nbsp;</p>\r\n<p>Why does the saveSelfExtractor looking for '<strong>c:\\Documents and Settings\\fdv\\Desktop\\vdb\\' </strong>path ?? I didn't mentionned it anywhere except to read my xml file...</p>\r\n<p>I've tried to change the icon link&nbsp;<span style=\"font-family:Consolas, 'Courier New', Courier, monospace;white-space:pre\">sfxOptions.IconFile = <span style=\"color:#A31515\">&quot;test\\\\client_vdb.ico&quot;</span>; and guess what..<span style=\"font-family:'Segoe UI', 'Microsoft Sans Serif', Arial, Geneva, sans-serif;white-space:normal\">Error reading icon '<strong>c:\\Documents and Settings\\fdv\\Desktop\\vdb\\</strong>test\\client_vdb.ico' -- The system cannot find the file specified.&nbsp;</span></span></p>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-family:Consolas, 'Courier New', Courier, monospace;white-space:pre\"><span style=\"font-family:'Segoe UI', 'Microsoft Sans Serif', Arial, Geneva, sans-serif;white-space:normal\">Please help me !!!</span></span></p>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-family:Consolas, 'Courier New', Courier, monospace;white-space:pre\"><span style=\"font-family:'Segoe UI', 'Microsoft Sans Serif', Arial, Geneva, sans-serif;white-space:normal\">Fred.</span></span></p>",
    "PostedDate": "2009-10-20T03:24:33.6-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247739",
    "ThreadId": "70602",
    "Html": "<table border=0 width=800>\r\n<tbody>\r\n<tr>\r\n<td>\r\n<p>Fred, I'm trying to understand exactly what&nbsp;problem or problems you are experiencing.</p>\r\n<p>I understand that you have problems using the default icon on Windows Server 2003, but not on your XP Pro machine.&nbsp; And also, you&nbsp;have different problems when specifying a custom icon, on any machine. &nbsp;I'm happy to work through these things but we need to keep them <strong>separate </strong>so I can understand what is happening, and what specific problem we are trying to solve.&nbsp;&nbsp;</p>\r\n<p>Some recommendations</p>\r\n<ol>\r\n<li>\r\n<p>Regarding the problems with the default icon, yes, the Windows Server 2003 machine must have .NET Framework v3.5 SP1 installed.&nbsp; The icon files in Windows changed for Windows Vista - there is now a new image format supported by .ico files.&nbsp;&nbsp; Support for the new Vista icon files in the .NET C# compiler (which is used when producing a SFX file) came with .NET 3.5 SP1&nbsp; (or .NET 2.0 SP1, if you are running .NET 2.0). &nbsp; The default icon in DotNetZip includes an image in the new-for-Windows-Vista&nbsp;format.&nbsp; If you don't have the current .NET Framework patch, then the C# Compiler will generate the problem you reported:&nbsp; <em>error CVT1105: cannot seek in file,</em>&nbsp;at runtime, when referencing a Windows Vista icon, such as the default icon.&nbsp; Even if you don't use the default icon when creating a DotNetZip SFX, it's a good idea to make sure you have the latest .NET service pack, on all machines.&nbsp;</p>\r\n</li>\r\n<li>\r\n<p>When specifying a custom .ico file, why do you not specify the full path for your .ico file ?&nbsp; You are specifying &quot;client_vdb.ico&quot;.&nbsp; It seems that DotNetZip is pre-pending a relative path ('<strong>c:\\Documents and Settings\\fdv\\Desktop\\vdb\\').&nbsp;&nbsp; </strong>I don't know where that path comes from.&nbsp; Could it be your current working directory?&nbsp;&nbsp; In any case you can avoid this by using a full path.&nbsp;&nbsp;&nbsp;</p>\r\n</li>\r\n</ol></td>\r\n</tr>\r\n</tbody>\r\n</table>",
    "PostedDate": "2009-10-20T08:39:46.193-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247948",
    "ThreadId": "70602",
    "Html": "<p>Hi,</p>\r\n<p>I just downloaded the latest version DotNetZip v1.9.0.24 &nbsp;but I could not find SelfExtractorSaveOptions class in there. Is there any thing missing from this release??</p>\r\n<p>Regards</p>",
    "PostedDate": "2009-10-20T19:55:55.99-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "247988",
    "ThreadId": "70602",
    "Html": "<p>Not sure why you can't find it. Maybe you are referencing an older binary. Check ZipFile.LibraryVersion - it will tell you the version of DotNetZip that you are running against.</p>\r\n<p>I just checked the .chm file, which is generated from the source code. It includes the doc for SelfExtractorSaveOptions.</p>\r\n<p><img src=\"http://imgur.com/Tcjgw.png\" alt=\"\"></p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-10-21T00:22:25.317-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254601",
    "ThreadId": "70602",
    "Html": "<p>Looks like you've done a great deal of work on this and that's awesome. Thanks for your hard work.</p>\r\n<p>I would like to use the latest changes you have made but I can't get the source to compile (pulled it directly from SVN). Is there a place I can get the latest DLL?</p>\r\n<p>Here are a few errors I get when trying to compile:</p>\r\n<p>1. Missing singing file Ionic.snk</p>\r\n<p>2. Error reading resource file 'dotnetzip\\Zip Partial DLL\\Resources\\ZippedResources.zip' -- 'The system cannot find the file specified.' Zip Partial DLL</p>",
    "PostedDate": "2009-11-07T14:26:52.687-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254616",
    "ThreadId": "70602",
    "Html": "<p>Get the devkit from <a href=\"http://dotnetzip.codeplex.com/Release/ProjectReleases.aspx\">http://dotnetzip.codeplex.com/Release/ProjectReleases.aspx</a></p>\r\n<p>The default release is v1.8.&nbsp; You don't want that.&nbsp; You want the v1.9 release.&nbsp; Look in the far-right side, near the top, you'll see a box with release options.</p>\r\n<p><img src=\"http://i33.tinypic.com/29z8rah.jpg\" alt=\"\"></p>\r\n<p>When you click it you'll get a list of downloads. <br>Click the Devkit download. It has the latest DLL, the helpfile, and so on. &nbsp;</p>\r\n<p><img src=\"http://imgur.com/Z9u6u.png\" alt=\"\"></p>",
    "PostedDate": "2009-11-07T15:46:55.917-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254617",
    "ThreadId": "70602",
    "Html": "<p>Duh! He he he, thanks.</p>\r\n<p>I did get it but didn't realize the latest build with the desired changes was there.</p>",
    "PostedDate": "2009-11-07T15:50:10.757-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "261967",
    "ThreadId": "70602",
    "Html": "<p>Hello~~<br><br>Is it possible to set &nbsp;DefaultExtractDirectory always same as the file location itself?<br>In other words, I can extract zip to the directory where I execute it.<br><br>Thank you &nbsp;</p>",
    "PostedDate": "2009-11-30T10:28:35.473-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "261969",
    "ThreadId": "70602",
    "Html": "<p>oops...<br><br>I just find out....<br>the solution is don't set &quot;DefaultExtractDirectory&quot; property.</p>",
    "PostedDate": "2009-11-30T10:31:53.4-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]