namespace 清理数据
{
class Program
{
static void Main(string[] args)
{
string strDirName = "File";
int iWriteFlag = 0;
if (Directory.Exists(strDirName))
{
string[] strFiles = Directory.GetFiles(strDirName); foreach (var item in strFiles)
{
using (var streamReader = File.OpenText(Path.Combine(Directory.GetCurrentDirectory(), item)))
{
var lines = streamReader.ReadToEnd().Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].StartsWith("AB "))
{
iWriteFlag = 1;
}
if (iWriteFlag == 1)
{
File.AppendAllText("abstractFile.txt", Regex.Replace(lines[i], "[ ]{2,}", " ", RegexOptions.None));
}
if (lines[i].StartsWith("ZR "))
{
iWriteFlag = 0;
File.AppendAllText("abstractFile.txt", "\r\n");
}
Console.WriteLine(Math.Round(i*1.0 / lines.Length,2));
}
} }
} Console.Write("Done");
Console.ReadKey();
}
}
}