views:

1283

answers:

2

While trying to extract zip files i get the error

c:/path/name.zip is not RAR archive
No files to extract

my code is

    p.StartInfo.FileName = @"C:\Program Files\WinRAR\rar.exe";
    p.StartInfo.Arguments = string.Format("x -o- {2} \"{0}\" * \"{1}\"\\ ",
        szFN,
        outFolder,
        passWord == null ? "" : string.Format("-p\"{0}\"", passWord));

The GUI version can extract zip and 7z files. Why cant this? How can i extract zip and 7z files? (NOTE: I have different source code for 7zip. I guess i can merge the two and only use the above when the file has a rar extension. But i dont like that solution)

+2  A: 

rar.exe can indeed only unpack rar files. It's not at all the same as WinRAR.

For unpacking ZIP files in .NET, you might want to look at the DotNetZip library instead. It has a license compatible with commercial software, unlike CSharpZipLib.

If you need to support RAR as well, you can use UnRAR.dll with pinvoke:
http://www.rarlab.com/rar_add.htm
http://www.rarlab.com/rar/UnRARDLL.exe

Or this .NET unRAR libary:
http://www.chilkatsoft.com/rar-dotnet.asp

Perhaps this one for 7zip.

Mick
A: 

rar.exe indeed to unpack zip rar cab tar etc... files... the problem is evolution... too easy to use with zip files, but the old good and dear mr. phil katz forgot to pay the fee for the marketing... that's all folks!

Brush

Brush