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");
}
}
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.