Last active
May 18, 2018 07:54
-
-
Save longtth/c4f1f05de0e41d896ead684ba99adf76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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