Skip to content

Instantly share code, notes, and snippets.

@longtth
Last active May 18, 2018 07:54
Show Gist options
  • Select an option

  • Save longtth/c4f1f05de0e41d896ead684ba99adf76 to your computer and use it in GitHub Desktop.

Select an option

Save longtth/c4f1f05de0e41d896ead684ba99adf76 to your computer and use it in GitHub Desktop.
foreach (string folder in folders)
{
Check1Folder(ref totalFiles, ref totalError, folder);
}
private void Check1Folder(ref int totalFiles, ref int totalError, string folder)
{
string[] files = Directory.GetFiles(folder,"*.txt");
totalFiles += files.Length;
foreach (string file in files)
{
string correct = "Correct";
string comment = "";
int firstLine = 0;
int count = 0;
string[] lines = File.ReadAllLines(file);
if (lines.Length != 2)
{
correct = "Error";
comment = "File format error";
totalError++;
}
else
{
firstLine = Convert.ToInt32(lines[0]);
count = lines[1].Split(',').Length / 2;
if (firstLine != count)
{
correct = "Error";
comment = "File content error";
totalError++;
}
}
//vì code này sẽ show lên 1 cái winform nên chỗ này là gửi data vào trong cái DataTabe d,
// không có gì đặc biệt.
d.Rows.Add(Path.GetFileName(folder), Path.GetFileName(file), firstLine, count, correct, comment);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment