Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Input;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Diagnostics;
- using System.Resources;
- using Keystroke.API;
- using Keystroke;
- using System.Globalization;
- using System.Threading;
- namespace Прогаы
- {
- class Program
- {
- private static void OnChanged(Object source, FileSystemEventArgs e)
- {
- Console.OutputEncoding = Encoding.GetEncoding(1251);
- String name = "";
- String num = "";
- StreamReader sr;
- using (FileStream fs = File.Open(e.FullPath, FileMode.Open))
- {
- byte[] b = new byte[1024];
- UTF8Encoding temp = new UTF8Encoding(true);
- if (fs.Read(b, 0, b.Length) > 0)
- {
- String[] arr = temp.GetString(b).Split(' ');
- name = arr[0] + " " + arr[1];
- num = arr[2];
- }
- while (fs.Read(b, 0, b.Length) > 0)
- {
- File.AppendAllText("in.cpp", temp.GetString(b));
- }
- }
- /* using (sr = File.OpenText(e.Name))
- {
- String s = "";
- if ((s = sr.ReadLine()) != null)
- {
- String[] arr = s.Split(' ');
- name = arr[0] + " " + arr[1];
- num = arr[2];
- }
- while ((s = sr.ReadLine()) != null)
- {
- File.AppendAllText("in.cpp", s + "\n");
- }
- }*/
- String com = "contest=2018-02-25 " + num + "=in.cpp:VC++ > out.txt";
- Process.Start("local_contests.exe", com).WaitForExit();
- String res;
- using (sr = File.OpenText(e.Name))
- {
- String s = "";
- while ((s = sr.ReadLine()) != null)
- {
- if (s == "Checking...")
- break;
- }
- while ((s = sr.ReadLine()) != null)
- {
- File.AppendAllText("res.txt", s);
- }
- String[] arr = s.Split(' ');
- res = arr[arr.Length - 1];
- }
- }
- static void Main(string[] args)
- {
- FileSystemWatcher fsw = new FileSystemWatcher("C:"+'\\'+"Users"+ '\\'+"Lrnovo"+ '\\'+"Desktop");
- fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
- | NotifyFilters.FileName | NotifyFilters.DirectoryName;
- fsw.Created += new FileSystemEventHandler(OnChanged);
- fsw.Changed += new FileSystemEventHandler(OnChanged);
- fsw.EnableRaisingEvents = true;
- ConsoleKeyInfo key;
- do
- {
- key = Console.ReadKey();
- }
- while (key.Key != ConsoleKey.Escape);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement