title: c# Execute command line and return string
body: <p>I can't get this to return anything, I'm expecting a list of files in the current directory but it's returning nothing.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          PublishProject();
          Console.ReadLine();
      }
  
      public static void PublishProject()
      {
          //Create process
          var pProcess = new System.Diagnostics.Process
          {
              StartInfo =
                  {
                      FileName = "cmd.exe",
                      Arguments = "dir",
                      UseShellExecute = false,
                      RedirectStandardOutput = true,
                      WorkingDirectory = "C:\\"
                  }
          };
          pProcess.Start();
          Console.Write(pProcess.StandardOutput.ReadToEnd());
          pProcess.Close();
  
          Console.WriteLine("done");
      }
  }
  </code></pre>