Advertisement
artemgf

newProg

Feb 25th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.46 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 (sr = File.OpenText(e.Name))
  27.             {
  28.                 String s = "";
  29.                 if ((s = sr.ReadLine()) != null)
  30.                 {
  31.                     String[] arr = s.Split(' ');
  32.                     name = arr[0] + " " + arr[1];
  33.                     num = arr[2];
  34.                 }
  35.                 while ((s = sr.ReadLine()) != null)
  36.                 {
  37.                     File.AppendAllText("in.cpp", s+"\n");
  38.                 }
  39.             }
  40.             String com = "contest=2018-02-25 " + name + "=in.cpp:VC++ > out.txt";
  41.             Process.Start("local_contests.exe", com).WaitForExit();
  42.             String res;
  43.             using (sr = File.OpenText(e.Name))
  44.             {
  45.                 String s = "";
  46.                 while ((s = sr.ReadLine()) != null)
  47.                 {
  48.                     if (s == "Checking...")
  49.                         break;
  50.                 }
  51.                 while ((s = sr.ReadLine()) != null)
  52.                 {
  53.                     File.AppendAllText("res.txt", s);
  54.                 }
  55.                 String[] arr = s.Split(' ');
  56.                 res = arr[arr.Length - 1];
  57.             }
  58.         }
  59.  
  60.         static void Main(string[] args)
  61.         {
  62.  
  63.             FileSystemWatcher fsw = new FileSystemWatcher("C:"+'\\'+"Users"+ '\\'+"Lrnovo"+ '\\'+"Desktop");
  64.             fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
  65.               | NotifyFilters.FileName | NotifyFilters.DirectoryName;
  66.             fsw.Created += new FileSystemEventHandler(OnChanged);
  67.             fsw.Changed += new FileSystemEventHandler(OnChanged);
  68.             fsw.EnableRaisingEvents = true;
  69.             ConsoleKeyInfo key;
  70.             do
  71.             {
  72.                 key = Console.ReadKey();
  73.             }
  74.             while (key.Key != ConsoleKey.Escape);
  75.                    
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement