string strtxtPath = "C:\\freezip\\free.txt";
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// 1
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -r " + strzipPath + " " + strtxtPath;
在网上找了一些! 但是发现 当程序运行的时候 能够进入这段代码块 但是在进程里 找不到新添加的 winrar.exe的进程 大侠们 帮忙解决一下 感激不尽
15 个解决方案
#1
哪位懂的大侠 帮帮忙
#2
process1.start()
#3
#4
string strtxtPath = "C:\\freezip\\free.txt";
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// 1
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -r " + strzipPath + " " + strtxtPath;
WinRar不是系统自带的,是安装系统后再安装的,一般在C:\Program Files\WinRAR
process1.StartInfo.FileName = "WinRAR.exe";
我觉得这里应该指定绝对路径
如process1.StartInfo.FileName = "C:\Program Files\WinRAR
\WinRAR.exe";
没试过,不知道行不行。
process1.StartInfo.FileName = "Notepad.exe";//系统自带的就可以
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// 1
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -r " + strzipPath + " " + strtxtPath;
WinRar不是系统自带的,是安装系统后再安装的,一般在C:\Program Files\WinRAR
process1.StartInfo.FileName = "WinRAR.exe";
我觉得这里应该指定绝对路径
如process1.StartInfo.FileName = "C:\Program Files\WinRAR
\WinRAR.exe";
没试过,不知道行不行。
process1.StartInfo.FileName = "Notepad.exe";//系统自带的就可以
#5
我试过了 不可以
#6
调用这个方法后 进程启用了 但是执行的结果没有被实现啊! 在文件夹里没有发现压缩的文件啊
#7
sorry
process.StartInfo.WorkingDirectory = @"C:\WINDOWS\system32";//用这个指定路径
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/c " + dosCommand;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.StartInfo.WorkingDirectory = @"C:\WINDOWS\system32";//用这个指定路径
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/c " + dosCommand;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
#8
自己改一下
#9
还是不可以
#10
private void button1_Click(object sender, EventArgs e)
{
string strtxtPath = "C:\\freezip\\free.txt";
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = @"C:\Program Files\WinRAR\WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// process1.start();//当启动该方法的时候 会弹出rar的压缩文件的对话框 下面的内容不在执行
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -ibck -r " + strzipPath + " " + strtxtPath;
}
#11
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process.StartInfo.WorkingDirectory =@"C:\Program Files\WinRAR";
process1.StartInfo.FileName = @"WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -ibck -r " + strzipPath + " " + strtxtPath;
注意红色,这个是你安装压缩包的地方,看C:\Program Files\WinRAR下面有没有WinRAR.exe这个文件
process.StartInfo.WorkingDirectory =@"C:\Program Files\WinRAR";
process1.StartInfo.FileName = @"WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -ibck -r " + strzipPath + " " + strtxtPath;
注意红色,这个是你安装压缩包的地方,看C:\Program Files\WinRAR下面有没有WinRAR.exe这个文件
#12
你的代码还少了这个process1.Start();
#13
private void button1_Click(object sender, EventArgs e)
{
string strtxtPath = "C:\\freezip\\free";
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.WorkingDirectory = @"C:\Program Files\WinRAR";
process1.StartInfo.FileName = "WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// process1.start();//当启动该方法的时候 会弹出rar的压缩文件的对话框 下面的内容不在执行
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
process1.StartInfo.Arguments = " a " + strzipPath + " " + strtxtPath + " -r ";
}
不可以
#14
不知道问题到底出在哪里了 是不是
process1.StartInfo.Arguments = " a " + strzipPath + " " + strtxtPath + " -r ";
这里的执行命令有问题呢? 求解 编译之后的命令为 " a C:\\freezip\\free.rar C:\\freezip\\free -r "
这里的执行命令有问题呢? 求解 编译之后的命令为 " a C:\\freezip\\free.rar C:\\freezip\\free -r "
#15
给命令行设断点的时候 会输出
单步执行: 正在逐过程执行非用户代码“System.Diagnostics.Process.StartInfo.get”
线程 '<无名称>' (0xa30) 已退出,返回值为 0 (0x0)。
单步执行: 正在逐过程执行非用户代码“System.Diagnostics.Process.StartInfo.get”
线程 '<无名称>' (0xa30) 已退出,返回值为 0 (0x0)。
#1
哪位懂的大侠 帮帮忙
#2
process1.start()
#3
#4
string strtxtPath = "C:\\freezip\\free.txt";
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// 1
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -r " + strzipPath + " " + strtxtPath;
WinRar不是系统自带的,是安装系统后再安装的,一般在C:\Program Files\WinRAR
process1.StartInfo.FileName = "WinRAR.exe";
我觉得这里应该指定绝对路径
如process1.StartInfo.FileName = "C:\Program Files\WinRAR
\WinRAR.exe";
没试过,不知道行不行。
process1.StartInfo.FileName = "Notepad.exe";//系统自带的就可以
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// 1
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -r " + strzipPath + " " + strtxtPath;
WinRar不是系统自带的,是安装系统后再安装的,一般在C:\Program Files\WinRAR
process1.StartInfo.FileName = "WinRAR.exe";
我觉得这里应该指定绝对路径
如process1.StartInfo.FileName = "C:\Program Files\WinRAR
\WinRAR.exe";
没试过,不知道行不行。
process1.StartInfo.FileName = "Notepad.exe";//系统自带的就可以
#5
我试过了 不可以
#6
调用这个方法后 进程启用了 但是执行的结果没有被实现啊! 在文件夹里没有发现压缩的文件啊
#7
sorry
process.StartInfo.WorkingDirectory = @"C:\WINDOWS\system32";//用这个指定路径
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/c " + dosCommand;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.StartInfo.WorkingDirectory = @"C:\WINDOWS\system32";//用这个指定路径
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/c " + dosCommand;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
#8
自己改一下
#9
还是不可以
#10
private void button1_Click(object sender, EventArgs e)
{
string strtxtPath = "C:\\freezip\\free.txt";
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = @"C:\Program Files\WinRAR\WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// process1.start();//当启动该方法的时候 会弹出rar的压缩文件的对话框 下面的内容不在执行
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -ibck -r " + strzipPath + " " + strtxtPath;
}
#11
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process.StartInfo.WorkingDirectory =@"C:\Program Files\WinRAR";
process1.StartInfo.FileName = @"WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -ibck -r " + strzipPath + " " + strtxtPath;
注意红色,这个是你安装压缩包的地方,看C:\Program Files\WinRAR下面有没有WinRAR.exe这个文件
process.StartInfo.WorkingDirectory =@"C:\Program Files\WinRAR";
process1.StartInfo.FileName = @"WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
strzipPath = "C:\\freezip\\free";//默认压缩方式为 .rar
process1.StartInfo.Arguments = " a -ibck -r " + strzipPath + " " + strtxtPath;
注意红色,这个是你安装压缩包的地方,看C:\Program Files\WinRAR下面有没有WinRAR.exe这个文件
#12
你的代码还少了这个process1.Start();
#13
private void button1_Click(object sender, EventArgs e)
{
string strtxtPath = "C:\\freezip\\free";
string strzipPath = "C:\\freezip\\free.rar";
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.WorkingDirectory = @"C:\Program Files\WinRAR";
process1.StartInfo.FileName = "WinRAR.exe";
process1.StartInfo.CreateNoWindow = true;
//// process1.start();//当启动该方法的时候 会弹出rar的压缩文件的对话框 下面的内容不在执行
////压缩c:\freezip\free.txt(即文件夹及其下文件freezip\free.txt)
////到c:\freezip\free.rar
process1.StartInfo.Arguments = " a " + strzipPath + " " + strtxtPath + " -r ";
}
不可以
#14
不知道问题到底出在哪里了 是不是
process1.StartInfo.Arguments = " a " + strzipPath + " " + strtxtPath + " -r ";
这里的执行命令有问题呢? 求解 编译之后的命令为 " a C:\\freezip\\free.rar C:\\freezip\\free -r "
这里的执行命令有问题呢? 求解 编译之后的命令为 " a C:\\freezip\\free.rar C:\\freezip\\free -r "
#15
给命令行设断点的时候 会输出
单步执行: 正在逐过程执行非用户代码“System.Diagnostics.Process.StartInfo.get”
线程 '<无名称>' (0xa30) 已退出,返回值为 0 (0x0)。
单步执行: 正在逐过程执行非用户代码“System.Diagnostics.Process.StartInfo.get”
线程 '<无名称>' (0xa30) 已退出,返回值为 0 (0x0)。