0

I want to make single exe file that will extract a Folder with a lot of stuff inside.

I want this exe to work on computers with .net 4.0

I was trying to decompress embedded zip archive with the folder, but it is not simple with .net 4.0

9
  • If you by saying "it is not simple with .net 4.0" are referring to that you cannot use the ZipFile class, I have something good to tell you: The ZipFile class is actually usable in .NET 4.0! You just have to import the System.IO.Compression.FileSystem.dll file, which is located somewhere in %SystemRoot%\Microsoft.NET\assembly\GAC_MSIL. Try searching for it there, and when found just import it as a reference to your project and it'll work! Commented May 5, 2016 at 19:53
  • @Visual Vincent, The primary reference "System.IO.Compression.FileSystem" could not be resolved because it has an indirect dependency on the framework assembly "System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "System.IO.Compression.FileSystem" or retarget your application to a framework version which contains "System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". Commented May 9, 2016 at 9:39
  • It works for me? I imported it from %SystemRoot%\Microsoft.NET\assembly\GAC_MSIL\System.IO.Compression.FileSystem\v4.0_4.0.0.0__b77a5c561934e089\System.IO.Compression.FileSystem.dll. Commented May 9, 2016 at 12:32
  • @VisualVincent, yes, i imported this file as a reference(right click on references->add reference->browse->choose). wtf, isn't 4.0 equal with 4.0.0.0? Commented May 9, 2016 at 12:48
  • Yes it is. But according to the error it sounds like the already existing System.IO.Compression namespace is the incorrect version... Are you sure you haven't accidentelly imported/referenced another version of it? Commented May 9, 2016 at 13:26

1 Answer 1

1

You should be able to do this by adding a .zip file to your C# installer project and setting its Build Action to "Embedded Resource." Then, your C# installer program would extract that file from itself using Assembly.GetManifestResourceStream, writing the contents of the stream to disk.

5
  • But how can I unzip it in .net 4.0? Commented May 7, 2016 at 6:06
  • I see from the comments on your question that the trouble you're having is finding a built-in zip/unzip library. I don't know much about that, but you could certainly use a third-party library like SharpZipLib or a command-line program like 7-Zip. (There's also a .NET wrapper for 7-Zip that allows you to link to the main DLL, but I haven't tried it.)
    – adv12
    Commented May 9, 2016 at 13:21
  • I prefer built-in, but I accept third-party. However, I am not sure I can create the situation that a single exe could use dll somehow Commented May 9, 2016 at 19:28
  • Yeah, a full-blown 7-Zip .exe might work best for you: make it and the 7z.dll both embedded resources, then when it's time to unpack, write both of them to disk along with the embedded .zip file, then use the .exe to unzip the .zip. Kinda ugly, but it could work.
    – adv12
    Commented May 9, 2016 at 20:14
  • Excellent! Glad to hear it.
    – adv12
    Commented May 16, 2016 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.