मैं xcopy का उपयोग कर बैकअप प्रोग्राम लिख रहा हूं और क्योंकि बहुत सी बड़ी फाइलें थोड़ी देर लगती हैं इसलिए मैं प्रगति दिखाना चाहता हूं। जब मैं मानक आउटपुट प्राप्त करने के लिए StreamReader का उपयोग करने का प्रयास करता हूं, तो जब मैं डीबग करता हूं तो यह त्रुटि संदेश होता है। "प्रक्रिया स्ट्रीम पर तुल्यकालिक और एसिंक्रोनस ऑपरेशन मिश्रण नहीं कर सकता।"मैं सी # में एक प्रक्रिया के आउटपुट को पढ़ने की कोशिश कर रहा हूं लेकिन मुझे यह संदेश मिलता है "प्रक्रिया स्ट्रीम पर तुल्यकालिक और असीमित ऑपरेशन मिश्रण नहीं कर सकता।"
public void backup_worker_DoWork(object sender, DoWorkEventArgs e)
{
int loop = 1;
backup_worker.WorkerReportsProgress = true;
Process xcopy = new Process();
ProcessStartInfo startinfo = new ProcessStartInfo();
startinfo.CreateNoWindow = true;
startinfo.UseShellExecute = false;
startinfo.RedirectStandardError = true;
startinfo.RedirectStandardOutput = true;
startinfo.FileName = Environment.CurrentDirectory + "\\xcopy.exe";
startinfo.Arguments = '"' + source + '"' + " " + '"' + target + '"' + " " + "/s /e /y";
xcopy.StartInfo.RedirectStandardOutput = true;
xcopy.StartInfo = startinfo;
xcopy.Start();
xcopy.BeginErrorReadLine();
xcopy.BeginOutputReadLine();
StreamReader sr = xcopy.StandardOutput;
while (loop > 0)
{
progress = sr.ReadLine();
output_list.Items.Add(progress);
}
xcopy.OutputDataReceived += new DataReceivedEventHandler(backup_worker_OutputDataRecieved);
xcopy.ErrorDataReceived += new DataReceivedEventHandler(backup_worker_ErrorDataReceived);
xcopy.WaitForExit();
backup_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backup_worker_RunWorkerCompleted);
}
void backup_worker_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
}
void backup_worker_OutputDataRecieved(object sender, DataReceivedEventArgs e)
{
}
void backup_worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
MessageBox.Show("Completed");
}
कृपया मदद करें। अग्रिम