c#中xcopy的进度报告 [英] Progress report of xcopy in c#

查看:342
本文介绍了c#中xcopy的进度报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Diagnostics.Process process = new System.Diagnostics.Process();

System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();

startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

startInfo.FileName =cmd.exe;

startInfo.Arguments =/ c copy \ D:dfs.jpg C:dfee.jpg;

process.StartInfo = startInfo;

process.Start();





i想要计算c#UI的进度,使用进度条

谢谢

解决方案

< blockquote>如果您在副本上使用/ z选项,它会向控制台屏幕报告进度百分比。

 copy / z sourcefile.ext destfile.ext 

您可以捕获文本输出并将其处理到您自己的进度条中,但没有整洁的方法来执行它 - 它不会调用委托人,或发出事件的信号,因为它是一个OC命令行操作,不打算在你的代码中使用。


System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c copy \"D:dfs.jpg C:dfee.jpg";
process.StartInfo = startInfo;
process.Start();


i want to calculate the progress in c# UI ,using progress bar
Thanks

解决方案

If you use the "/z" option on your copy, it reports percentage progress to the console screen.

copy /z sourcefile.ext destfile.ext

You could capture the text output and process it into your own progress bar, but there is no "tidy" way to do it - it won't call a delegate, or signal an event because it's an OC command line operation, not intended to be used from your code.


这篇关于c#中xcopy的进度报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆