.NET
Microsoft Technologies based on the .NET software framework.
3,345 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am encountering a performance problem while executing a bash command from dot-net-core 5.0.
string source_location = new FileInfo(files.FirstOrDefault()).DirectoryName;
string tmp_file_name = Guid.NewGuid().ToString().ToUpper();
string tmp_full_name = Path.Combine(source_location, tmp_file_name) + ".txt";
File.WriteAllLines(tmp_full_name, files);
string cmd = $"cat {tmp_full_name} | xargs mv -t {targetFolder}";
string time_now = DateTime.Now.ToString();
Tuple<string, string> result = ShellHelper.Bash(cmd);
string time_finish = DateTime.Now.ToString();
string number_of_files = files.Count.ToString();
log.Info(String.Format("\n [START]: {0} \n [END]: {1} \n [RESULT_BASH]: {2} \n [STATE_BASH]: {3}
\n [NUMBER_OF_FILES]: {4} -------------- \n", time_now, time_finish, result.Item1,
result.Item2, number_of_files));
private static class ShellHelper var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "/bin/bash",
Arguments = $"-c \"{escapedArgs}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
}
};
process.Start();
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
return Tuple.Create(result, process.ExitCode.ToString());
}
}
89347-750d00a0-e017-4936-93e1-95d224ebb6e4.txt89348-difference-of-result.txt