C# 文件比较差异
参考:https://www.cnblogs.com/vaevvaev/p/7115721.html
这里我就比较2个文件 使用了fc命令。
2个文件路径如下 path1,path2
static void Main(string[] args)
{
string path1 = @"C:\Users\Tyler\Desktop\1.txt";
string path2 = @"C:\Users\Tyler\Desktop\2.txt";
string result = RunCmd("FC "+path1+" "+path2);
Console.WriteLine(result);
Console.ReadLine();
}
public static string RunCmd(string cmd)
{
Process proc = new Process();
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
proc.StandardInput.WriteLine(cmd);
proc.StandardInput.WriteLine("exit");
string outStr = proc.StandardOutput.ReadToEnd();
proc.Close();
return outStr;
}