F#进程标准已删除\n
我的代码片段取自: c#中的代码应该与上面列出的f#等效,工作起来很好:F#进程标准已删除\n,f#,F#,我的代码片段取自: c#中的代码应该与上面列出的f#等效,工作起来很好: private static string[] RetrieveOrphanedBranches(string directory) { StringBuilder outputStringBuilder = new StringBuilder(); ProcessStartInfo startInfo = new ProcessStartInfo(); Pr
private static string[] RetrieveOrphanedBranches(string directory)
{
StringBuilder outputStringBuilder = new StringBuilder();
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.WorkingDirectory = directory;
startInfo.UseShellExecute = false;
startInfo.Arguments = "branch -vv";
startInfo.FileName = "git";
p.StartInfo = startInfo;
p.OutputDataReceived += (sender, eventArgs) => outputStringBuilder.AppendLine(eventArgs.Data);
p.Start();
p.BeginOutputReadLine();
p.WaitForExit();
var l = outputStringBuilder.ToString().Split(new char[] { '\n' });
return l;
}
有没有办法防止f#从进程输出中删除新行字符?这里的“等效”可以自由使用
C#代码
F#代码:
因此,在C#中,代码行(带\n)被添加到输出中。在F#中,添加时不带\n。在这两种语言中都使用AppendLine。这里的“等效”可以自由使用
C#代码
F#代码:
因此,在C#中,代码行(带\n)被添加到输出中。在F#中,添加时不带\n。在两者中都使用AppendLine
let p = executeProcess ("git","branch -vv")
printfn "%d" (p.stdout.IndexOf('\n'))
private static string[] RetrieveOrphanedBranches(string directory)
{
StringBuilder outputStringBuilder = new StringBuilder();
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.WorkingDirectory = directory;
startInfo.UseShellExecute = false;
startInfo.Arguments = "branch -vv";
startInfo.FileName = "git";
p.StartInfo = startInfo;
p.OutputDataReceived += (sender, eventArgs) => outputStringBuilder.AppendLine(eventArgs.Data);
p.Start();
p.BeginOutputReadLine();
p.WaitForExit();
var l = outputStringBuilder.ToString().Split(new char[] { '\n' });
return l;
}
p.OutputDataReceived += (sender, eventArgs) => outputStringBuilder.AppendLine(eventArgs.Data);
p.OutputDataReceived.Add(fun args -> output.Append(args.Data) |> ignore)