I have installed 7-zip 4.65 on my machine at C:\Program files. I want to use it in C# code to zip a file. The file name will be provided by the user dynamically. Can any one please provide a sample code on how to use 7zip in C# code?
Instead of using 7-zip, I recommend using SharpZipLib, which has code samples, documentation, written as 100% managed code. I've had great success with it, and its fairly simple to use.
Have you tried this C# interface for 7zip: http://www.codeproject.com/KB/DLL/cs_interface_7zip.aspx
[edit] Looks like this has been answered already: http://stackoverflow.com/questions/449998/free-compression-library-for-c-which-supports-7zip-lzma
further libraries:
http://sevenzipsharp.codeplex.com/
http://www.7-zip.org/sdk.html - From the official site so probably best to use this
Or you can use the J# zip library (which is included in the .Net Framework) a sample: http://weblogs.asp.net/jgalloway/archive/2007/10/25/creating-zip-archives-in-net-without-an-external-library-like-sharpziplib.aspx
I suppose if you wish to use the installed one you have in c:\program files, you could just use System.Diagnostics.Process
to run command line apps -
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
Passing parameters is easy too. There are plenty of examples here - http://www.c-sharpcorner.com/UploadFile/DipalChoksi/ShellCommandsInCS12032005042031AM/ShellCommandsInCS.aspx