What is the command-line for rar and unrar?
I need to rar test.txt to test.rar, and to unrar test.rar to test.txt.
I need to put this functionality in a C# WinForm.
I have Windows XP and WinRar install
Thanks in advance.
Take a look at SevenZipSharp which supports RAR format as well as others. This way you won't have to rely on external applications.
http://www.respower.com/page_tutorial_unrar
So the commands are: rar and unrar
Source: I googled it.
SharpZipLib might help (I'm not sure if they support RAR but you can compress the files in other formats i.e ZIP)
You should clear out your question and tag it correctly.
Do you ask for the command line parameters for winrar?
For this a simple rar /? should help you out.
Or do you ask for a way to unrar packages via .NET-libraries?.
For that the other answers give you lot of information already.
Anyway, your commenter is right, do not shell out to programs, that do not come with the system, unless your installer ensures the other program to be there.
Related
I have been trying to write a simple Markdown -> docx parser/writer, but am completely stuck with the last part, which should be the easiest: i.e. compressing the folder into a .docx that Word, or any other .docx reader, will recognize.
My parser-writer is irrelevant really: I have this problem if I simply unzip any old Word-produced *.docx and then try to recompress it with the usual compression utilities, giving it the file-ending docx. Is there some mysterious header I should be adding, or do I need a special OPC compression utility, or what?
I don't so much want a tool that will do this, as to figure out what is supposed to be there. It seems to be independent of the WordprocessingML specification.
Needless to say I don't know anything about compression. Everything I can find via Google has to do with fancy utilities you can use in business, but I'm making a little executable that would be GPLd or something, and should work on anything.
The most common problem around manually zipping together Open XML documents is that it will not work if you zip the directory instead of the contents. In other words, the[content_types].xml file, and the word, docProps, and _rels directories need to reside at the root level of the zip file.
Here are steps to unzip my.docx and re-zip:
% mkdir unzipped
% cd unzipped/
% unzip ../my.docx
% zip -r ../rezipped.docx *
% open ../rezipped.docx
The compression algorithm used is "Zip" (Base 64) compression.
7zip seems to offer this, though i have no tested it.
Further to what Mica said, the contents of the ZIP file are organised according to the Open Packaging Convention; cf. Microsoft's Essentials of the Open Packaging Convention.
You can use the .NET System.IO.Packaging to make and manipulate .docx files; this class is implemented in the Mono project.
What is the best way to convert a whole folder (including it's contents) into a .zip file?
There is no class for doing this in the .NET Framework itself, but you can use some of the third-party libraries. An open-source DotNetZip seems to be quite good and has a lot of examples to get you started. You'll just need to recursively iterate over all files in the given folder and add them one by one.
This appears to have your answer.
I've used the Xceed Zip libraries in the past for this and found them very easy to use. The full license is quite pricey, but they do have a 45 day, 100% functional free trial available here:
http://xceed.com/Zip_Net_Intro.html
I want to compress and decompress a folder using C#. The problem with GZipStream is that it takes filenames and hence I need to write a recursive logic.
Can I somehow do it like, give source folder name and destination filename to compress the complete folder with hierarchy. I need to do vice-versa for de-compressing the folder as well.
If its not possible through C#/.net directly please suggest some Free 3rd party.
I've used the free SharpZipLib multiple times and I'd recommend that you take a look at it. It's quite easy to use and have worked well for all my use cases.
Now included in .NET 4.5 if you'd rather stay off non microsoft libs.
System.IO.Compression.ZipArchive Class
GZip only ever deals with single files, which is why under *nix you end up having to archive them into a TAR file first which is then compressed.
If you want multiple files/folders you'll need a format which supports it, like ZIP.
You might want to thus look at: http://www.sharpdevelop.net/OpenSource/SharpZipLib/
You could take a look at this library instead.
Take a look at DotNetZip Lib.
I have a CAB file generated from CABARC.EXE. I need to extract the file using ASP.Net C#.Net.
How to do it in C#.net itself? I don't want to use the same CABARC.EXE for extraction. Because we don't use this tool in production environment.
Please give your valuable suggestions/code to achieve this task.
Thanks in advance
Ganesh.
I googled this for you.
http://www.codeproject.com/KB/files/CABCompressExtract.aspx
Looks like it does everything you want.
If you want a native C# solution I suggest you start with the file specification for CAB files here:
http://msdn.microsoft.com/en-us/library/cc483132(EXCHG.80).aspx
Have a look at https://learn.microsoft.com/en-us/previous-versions//bb267310(v=vs.85)#microsoft-cabinet-file-format
There you have a file format description for the CAB file.
I am searching for a way to add several files into one file, much like a Zip file. I need to be able to create a file container on the fly and add several word documents, images and other important files into the container. My criteria is that you don't need to install any additional software on the computer (preferebly only a .DLL file that i can include in my project), that the program is free and that you can encrypt the data.
Anyone know of any good container programs that has support for these 2 criterias or if anyone know any good information about how to create your own container.
Patrick
Does it have to be like a zip file, or can it be a zip file?
Are you using .NET Framework 3.0 or 3.5? If so, look at
System.IO.Packaging.ZipPackage
This discussion has a section about it.
In addition to DotNetZip (licensed with Microsoft Public License) that Jay Riggs mentions, there's SharpZipLib (licensed with GPL). Whichever you choose, be sure the terms of the license match your understanding of the word "free".
If you can use ZipPackage, one benefit is that you don't need to think about license terms (beyond those of developing any other .NET app).
EDIT: DotNetZip and SharpZipLib support encryption. I don't see that ZipPackage does, but you could look at System.IO.Packaging.EncryptedPackageEnvelope.
I used DotNetZip in a project and it worked really well. I would recommend using it. It supports encryption and is easy to use.
http://www.codeplex.com/DotNetZip
User .Net GZipStream class(System.IO.Compression namespace.) to compress and decompress files. You can find more information on
MSDN Link
GZIP Compression
I have personally used this technique to decomress .zip file. Click Here