0

I've poked around looking for a zip function from with Visual Studio but haven't found anything.

Is there a function? Reason I'm asking, is I'm currently creating a process within my code to call 7zip, but this program isn't installed on all user machines and installing the program is an option, just not an ideal option.

Suggestions?

Muhnamana
  • 1,014
  • 13
  • 34
  • 57

2 Answers2

2

Try the System.IO.Compression library that comes with C#: ZipFile Class

  • Please note that this uses the 4.5 Version of the .NET Framework – Benjamin Danger Johnson Sep 27 '12 at 20:34
  • I assume 4.5 .NET Framework would need to be on each machine that will be executing the zip process? – Muhnamana Oct 01 '12 at 14:11
  • Is there a way to check the users machine and install 4.5 if it's needed? – Muhnamana Oct 01 '12 at 14:11
  • 1
    actually, I'm not sure off the top of my head how to make a program to install .Net 4.5, but you can query it with something like "Environment.Version()". If you want to use something lower than 4.5 you can try the [ZipPackage](http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx) Class or Use [DotNetZip](http://dotnetzip.codeplex.com/) like Ollie Jones recommended. – Benjamin Danger Johnson Oct 01 '12 at 16:53
  • Alright, thanks. I'll ask another question to see if its possible to install on the fly per say. – Muhnamana Oct 01 '12 at 17:05
  • So I downloaded and installed .net 4.5, but how do I activate it within Visual Studio? Download this file: http://www.microsoft.com/en-us/download/details.aspx?id=30653 – Muhnamana Oct 03 '12 at 13:14
  • 1
    you just need to change the .Net version in your solution. You should be able to do this in Visual Studio of you right click on the solution in the solution explorer and go into properties. – Benjamin Danger Johnson Oct 03 '12 at 16:24
1

I have used dotnetzip.codeplex.com with very good results. There is definitely some coding and qa work to do to ensure it's handling your data correctly. But you're quite right that it's easier to deploy to random client machines than calling out to 7zip.

O. Jones
  • 103,626
  • 17
  • 118
  • 172