Windowsコマンド-"DIR/S / B"を使用してサーバーからファイルのリストを取得しようとしています。出力は膨大です(約400MB)。以下のアプローチで取得しようとすると、処理に数時間かかります。それを行うためのより速い方法はありますか?
string path = args[0];
var start = DateTime.Now;
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "dir /s/b " + path );
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
//string [] result = proc.StandardOutput.ReadToEnd().Split('\n'); ;
StreamWriter writer = new StreamWriter("FileList.lst");
while (proc.StandardOutput.EndOfStream != true)
{
writer.WriteLine(proc.StandardOutput.ReadLine());
writer.Flush();
}
writer.Close();