Advertisement
artemgf

Untitled

Feb 28th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. using System;
  2. using System.Windows.Input;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.IO;
  8. using System.Diagnostics;
  9. using System.Resources;
  10. using Keystroke.API;
  11. using Keystroke;
  12. using System.Globalization;
  13. using System.Threading;
  14.  
  15. namespace Прогаы
  16. {
  17.  
  18. class Program
  19. {
  20. private static void OnChanged(Object source, FileSystemEventArgs e)
  21. {
  22. Console.OutputEncoding = Encoding.GetEncoding(1251);
  23. String name = "";
  24. String num = "";
  25. StreamReader sr;
  26. using (FileStream fs = File.Open(e.FullPath, FileMode.Open))
  27. {
  28. byte[] b = new byte[1024];
  29. UTF8Encoding temp = new UTF8Encoding(true);
  30.  
  31. if (fs.Read(b, 0, b.Length) > 0)
  32. {
  33. String[] arr = temp.GetString(b).Split(' ');
  34. name = arr[0] + " " + arr[1];
  35. num = arr[2];
  36. }
  37. while (fs.Read(b, 0, b.Length) > 0)
  38. {
  39. File.AppendAllText("in.cpp", temp.GetString(b));
  40. }
  41. }
  42. /* using (sr = File.OpenText(e.Name))
  43. {
  44. String s = "";
  45. if ((s = sr.ReadLine()) != null)
  46. {
  47. String[] arr = s.Split(' ');
  48. name = arr[0] + " " + arr[1];
  49. num = arr[2];
  50. }
  51. while ((s = sr.ReadLine()) != null)
  52. {
  53. File.AppendAllText("in.cpp", s + "\n");
  54. }
  55. }*/
  56. String com = "contest=2018-02-25 " + num + "=in.cpp:VC++ > out.txt";
  57. Process.Start("local_contests.exe", com).WaitForExit();
  58. String res;
  59. using (sr = File.OpenText(e.Name))
  60. {
  61. String s = "";
  62. while ((s = sr.ReadLine()) != null)
  63. {
  64. if (s == "Checking...")
  65. break;
  66. }
  67. while ((s = sr.ReadLine()) != null)
  68. {
  69. File.AppendAllText("res.txt", s);
  70. }
  71. String[] arr = s.Split(' ');
  72. res = arr[arr.Length - 1];
  73. }
  74. }
  75.  
  76. static void Main(string[] args)
  77. {
  78.  
  79. FileSystemWatcher fsw = new FileSystemWatcher("C:"+'\\'+"Users"+ '\\'+"Lrnovo"+ '\\'+"Desktop");
  80. fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
  81. | NotifyFilters.FileName | NotifyFilters.DirectoryName;
  82. fsw.Created += new FileSystemEventHandler(OnChanged);
  83. fsw.Changed += new FileSystemEventHandler(OnChanged);
  84. fsw.EnableRaisingEvents = true;
  85. ConsoleKeyInfo key;
  86. do
  87. {
  88. key = Console.ReadKey();
  89. }
  90. while (key.Key != ConsoleKey.Escape);
  91.  
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement