Guest User

Untitled

a guest
May 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. foreach (string folder in folders)
  2. {
  3. Check1Folder(ref totalFiles, ref totalError, folder);
  4. }
  5.  
  6. private void Check1Folder(ref int totalFiles, ref int totalError, string folder)
  7. {
  8. string[] files = Directory.GetFiles(folder,"*.txt");
  9. totalFiles += files.Length;
  10. foreach (string file in files)
  11. {
  12. string correct = "Correct";
  13. string comment = "";
  14. int firstLine = 0;
  15. int count = 0;
  16. string[] lines = File.ReadAllLines(file);
  17. if (lines.Length != 2)
  18. {
  19. correct = "Error";
  20. comment = "File format error";
  21. totalError++;
  22. }
  23. else
  24. {
  25. firstLine = Convert.ToInt32(lines[0]);
  26. count = lines[1].Split(',').Length / 2;
  27.  
  28. if (firstLine != count)
  29. {
  30. correct = "Error";
  31. comment = "File content error";
  32. totalError++;
  33. }
  34. }
  35. //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,
  36. // không có gì đặc biệt.
  37. d.Rows.Add(Path.GetFileName(folder), Path.GetFileName(file), firstLine, count, correct, comment);
  38. }
  39. }
Add Comment
Please, Sign In to add comment