Process myProcess = new Process(); myProcess.StartInfo.FileName = "cmd.exe"; string a = @"/c echo Y| ping www.yahoo.com>d:temp.txt"; myProcess.StartInfo.Arguments = a; myProcess.StartInfo.UseShellExecute=false; myProcess.StartInfo.RedirectStandardOutput = true; myProcess.StartInfo.CreateNoWindow = true ; myProcess.Start();But it did not work: nothing was written into the file temp.txt and I did not get any error message. Can you help me to find where the problem is?
ProcessStartInfo info = new ProcessStartInfo( "cmd.exe", @"/c echo Y| ping localhost"); info.UseShellExecute = false; info.RedirectStandardOutput = true; info.CreateNoWindow = true ; Process p = Process.Start(info); string output = p.StandardOutput.ReadToEnd(); Response.Write(output);Writing files (fixed file names, specially) in an ASP.NET application is not a good idea as multiple threads can try to write the same file simultaneously.
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ...continue reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers.continue reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.