本文整理汇总了C#中System.IO.FileInfo.ReadLine方法的典型用法代码示例。如果您正苦于以下问题:C# System.IO.FileInfo.ReadLine方法的具体用法?C# System.IO.FileInfo.ReadLine怎么用?C# System.IO.FileInfo.ReadLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了System.IO.FileInfo.ReadLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunInternalDiff
private void RunInternalDiff(string file1, string file2, bool processTabs = true)
{
List<string> lines1 = new List<string>();
List<string> lines2 = new List<string>();
using (var fs = new System.IO.FileInfo(file1).OpenText())
{
while (true)
{
if (fs.EndOfStream)
break;
string line = fs.ReadLine();
if (processTabs)
line = line.Replace("\t", " ");
lines1.Add(line);
}
}
using (var fs = new System.IO.FileInfo(file2).OpenText())
{
while (true)
{
if (fs.EndOfStream)
break;
string line = fs.ReadLine();
if (processTabs)
line = line.Replace("\t", " ");
lines2.Add(line);
}
}
List<Utilities.Diff.commonOrDifferentThing> diff = null;
diff = Versionr.Utilities.Diff.diff_comm2(lines1.ToArray(), lines2.ToArray(), true);
int line0 = 0;
int line1 = 0;
Printer.PrintMessage("--- a/{0}", file1);
Printer.PrintMessage("+++ b/{0}", file2);
List<Region> regions = new List<Region>();
Region openRegion = null;
Region last = null;
// cleanup step
bool doCleanup = true;
if (!doCleanup)
goto Display;
for (int i = 1; i < diff.Count - 1; i++)
{
if (diff[i - 1].common == null || diff[i - 1].common.Count == 0)
continue;
if (diff[i + 1].common == null || diff[i + 1].common.Count == 0)
continue;
int cf0 = diff[i].file1 == null ? 0 : diff[i].file1.Count;
int cf1 = diff[i].file2 == null ? 0 : diff[i].file2.Count;
if ((cf0 == 0) ^ (cf1 == 0)) // insertion
{
List<string> target = cf0 == 0 ? diff[i].file2 : diff[i].file1;
List<string> receiver = diff[i - 1].common;
List<string> source = diff[i + 1].common;
int copied = 0;
for (int j = 0; j < target.Count && j < source.Count; j++)
{
if (target[j] == source[j])
copied++;
else
break;
}
if (copied > 0)
{
target.AddRange(source.Take(copied));
source.RemoveRange(0, copied);
receiver.AddRange(target.Take(copied));
target.RemoveRange(0, copied);
}
}
}
for (int i = 0; i < diff.Count - 1; i++)
{
if (diff[i].common != null)
continue;
if (diff[i + 1].common == null)
{
var next = diff[i + 1];
diff.RemoveAt(i + 1);
foreach (var x in next.file1)
{
diff[i].file1.Add(x);
}
foreach (var x in next.file2)
{
diff[i].file2.Add(x);
}
i--;
continue;
}
if (diff[i + 1].common == null || diff[i + 1].common.Count == 0)
continue;
bool isWhitespace = true;
bool isShort = false;
bool isBrace = false;
if (diff[i + 1].common.Count * 2 <= diff[i].file1.Count &&
diff[i + 1].common.Count * 2 <= diff[i].file2.Count)
//.........这里部分代码省略.........