Calling batch file from code
I'm attempting to call a batch file in code. I run it when the program starts and then every 10 minutes ( for testing purposes ). However, when the function is called throug开发者_高级运维h the timer it takes about 5 minutes to process it, but when I do it through start up it only takes 30 seconds.Its copying images from point A to point B on the local computer. The amount to be copied is 400 files or so.
net use t: "image source" /persistent:yes
xcopy t: "c:\images" /C /Q /I /Y
net use /delete t:
Here is the code for the batch file.Doing net use because of problems with permissions
System.Diagnostics.ProcessStartInfo p = new ProcessStartInfo(@"c:\getDiscImages.bat");
System.Diagnostics.Process proc = new Process();`
p.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo = p;
proc.Start();
proc.WaitForExit();
This is the code in c#. It works its just a tad bit slow. Any help is greatly appreciated as always.
精彩评论