Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# program with WinRAR

Tags:

c#

I want to design a c# program which can run program a 3rd exe application such as WinRAR. the program will browse for file and when then user click a button, the process to create archive will begin..!

I know using System.Diagnostics.Process.Start method can execute the .exe file. for eg.

Process.Start(@"C:\path\to\file.zip");

GetFile("filename","open winrar to execute the file") I need something like this. I wanna pass the file name to that 3rd application, without need to open winrar. Is it possible? How should i start? Any references/guidance/solution are very thankful.

thank you very much.

//UPDATED

Here is the code to open the WinRAR.exe program else the error message appeared.I pun it in button_click and accept file from txtDest.text using browse. So from here, instead of open the files, i want to to compress directly. I try to change "RAR.exe" or "UNRAR.exe" but it didnt work. It is right?

thank you.

 ProcessStartInfo startInfo = new ProcessStartInfo("WinRAR.exe");
 startInfo.WindowStyle = ProcessWindowStyle.Maximized;
 startInfo.Arguments = txtDest.Text;
 try
 {
   // Start the process with the info we specified.
   using (Process exeProcess = Process.Start(startInfo))
    {
        exeProcess.WaitForExit();
    }
  }
  catch
    {
        MessageBox.Show("Error Open");
    }
  }
like image 943
user147685 Avatar asked Sep 15 '09 01:09

user147685


People also ask

What is C is used for?

C is a general-purpose programming language and can efficiently work on enterprise applications, games, graphics, and applications requiring calculations, etc. C language has a rich library which provides a number of built-in functions. It also offers dynamic memory allocation.

What is C for computer?

C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners.

What is C language in English?

C is an imperative procedural language supporting structured programming, lexical variable scope, and recursion, with a static type system. It was designed to be compiled to provide low-level access to memory and language constructs that map efficiently to machine instructions, all with minimal runtime support.


1 Answers

For this you probably want to use unrar.dll which is the library distributed by RarLabs, the people who make Winrar. It contains all the functionality of WinRAR exposed as a COM interface. I used it recently in a project and it is quite good, exposes methods for opening and browsing archives, as well as compression and decompression.

http://www.rarlab.com/rar_add.htm scroll down to "UnRAR.dll UnRAR dynamic library for Windows software developers."

It comes with a really good set of examples including browsing an archive and API documentation.

like image 107
Dale Avatar answered Sep 21 '22 12:09

Dale