Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

1 solution

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.
 
Share this answer
 
Comments
jeffingeorge 22-Aug-13 2:35am    
can you give a example ?
OriginalGriff 22-Aug-13 3:21am    
No, because I have no need to do that - I don't use CMD commands to copy in my code (I use File.Copy which does the same job but doesn't require and external process)
But it should be simple - just capture the process STDOUT (or STDERR - I haven't checked) and examine it. The MSDN Process documentation should show you how.
jeffingeorge 22-Aug-13 3:31am    
This process am using for adb shell

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900