title: C# Process Standard Input
body: <p>I am currently trying to disconnect from a network folder through the command line and am using the following code:</p>
  
  <pre><code>System.Diagnostics.Process process2 = 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 NET USE F: /delete";
  startInfo.RedirectStandardError = true;
  startInfo.RedirectStandardInput = true;
  startInfo.RedirectStandardOutput = true;
  startInfo.UseShellExecute = false;
  startInfo.CreateNoWindow = true;
  process2.StartInfo = startInfo;
  process2.Start();
  
  StreamWriter sw = process2.StandardInput;
  sw.WriteLine("Y");
  sw.Close();
  
  process2.WaitForExit();
  process2.Close();
  </code></pre>
  
  <p>Occasionally, I get the message "Is it ok to continue disconnecting and force them closed? (Y/N) [N]", to which I want to reply "Y", but I seem to be having issues with that working. </p>
  
  <p>Does anyone know why my code is not inputting "Y" to standard input?</p>