我想要设计一个c#程序,它可以运行程序,一个第3 exe应用程序,如WinRAR。该程序将浏览文件,当用户单击一个按钮时,创建存档的过程将开始..!
我知道使用System.Diagnostics.Process.Start方法可以执行.exe文件。就像。
Process.Start(@"C:\path\to\file.zip");
GetFile(“文件名”,“打开winrar来执行文件”)我需要这样的东西。我想把文件名传递给第三个应用程序,而不需要打开winrar。有可能吗?我该怎么开始?任何参考/指导/解决方案都非常感谢。
非常感谢。
//更新的
下面是打开WinRAR.exe程序的代码,否则出现错误消息。我在button_click中使用双关语,然后使用浏览从txtDest.text接收文件。所以从这里开始,我想直接压缩文件,而不是打开文件。我试图更改"RAR.exe“或"UNRAR.exe”,但它没有起作用。这是对的?
谢谢。
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");
}
}
发布于 2009-09-15 01:44:12
为此,您可能希望使用unrar.dll,它是由RarLabs发布的库,是制作Winrar的人。它包含作为COM接口公开的WinRAR的所有功能。我最近在一个项目中使用了它,它非常好,公开了打开和浏览档案以及压缩和解压缩的方法。
add.htm向下滚动到“面向Windows软件开发人员的UnRAR.dll UnRAR动态库”。
它附带了一组非常好的示例,包括浏览存档和API文档。
发布于 2012-12-20 01:29:24
是的,我在这里重申一个完全死掉的问题,但我没有见过有人给出确切的答案(直到20分钟前我也是这样),所以让我把2和2放在一起:
命令行用法:rar.exe a <target .rar file> <file to rar> {<more files>}
您可以通过在名称周围添加引号来创建更复杂的名称,比如包含空格的名称。因此,您可能需要的程序是:
string targetArchiveName = "archive.rar",
targetFile = "testFile.txt";
ProcessStartInfo startInfo = new ProcessStartInfo("WinRAR.exe");
startInfo.WindowStyle = ProcessWindowStyle.Maximized;
startInfo.Arguments = string.Format("a \"{0}\" \"{1}\"",
targetArchiveName, targetFile);
try
{
// Start the process with the info we specified.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
{
MessageBox.Show("Error Open");
}
}发布于 2011-02-02 10:45:57
这个呢?
http://nunrar.codeplex.com/
https://stackoverflow.com/questions/1424673
复制相似问题