शैल के माध्यम से कमांड कमांड कैसे करें और सी # का उपयोग कर स्ट्रिंग के रूप में पूरा आउटपुट लौटाएं?सी # shell_exec
PHP के shell_exec() के बराबर।
धन्यवाद, उन्नत।
शैल के माध्यम से कमांड कमांड कैसे करें और सी # का उपयोग कर स्ट्रिंग के रूप में पूरा आउटपुट लौटाएं?सी # shell_exec
PHP के shell_exec() के बराबर।
धन्यवाद, उन्नत।
MSDN documentation on Process.StandardOutput प्रलेखन एक उदाहरण
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Write500Lines.exe";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
साथ ही आप मानक त्रुटि धारा को निकालने के लिए पसंद कर सकते हैं दर्शाता है।
प्रक्रिया वर्ग Standard Output और Standard Error, और OutputDataReceived और ErrorDataReceived प्राप्त घटनाओं में Process वर्ग
देखो का उपयोग करें।
CodeProject article here है, जो आपको उपयोगी मिल सकता है।
ठीक काम करता है, धन्यवाद! –