减少一些检查器的代码大小

Reduce the size of the code for some checker

我有两个功能,第一个从空磁带中清除文件,第二个删除重复项,我想合并它们

File.WriteAllLines(@".\temporal.txt",File.ReadAllLines(@".\temporal.txt").Where(l => !string.IsNullOrWhiteSpace(l)));

File.WriteAllLines(@".\temporal.txt",File.ReadAllLines(@".\temporal.txt").Distinct().ToArray());

您可以读取一次并执行所有操作,然后将其写入文件,而不是两次读写文件

喜欢,

var fileData = File.ReadAllLines(@".\temporal.txt")
                   .Where(l => !string.IsNullOrWhiteSpace(l))
                   .Distinct()
                   .ToArray();

File.WriteAllLines(@".\temporal.txt", fileData);