private void Form1_Load(object sender, EventArgs e) { var arguments = Environment.GetCommandLineArgs(); port = arguments.Length > 1 ? int.Parse(arguments[1]) : defaultPort; directory = arguments.Length > 2 ? arguments[2] : "."; notifyIcon.Text += ": " + port; try { server = new BasicServer(port, directory); } catch (Exception ex) { countTimeLabel.Text = "Error"; countTimeLabel.ForeColor = Color.Red; if (ex is HttpListenerException && ((HttpListenerException)ex).NativeErrorCode == 5) { MessageBox.Show("Require Administrator Right\r\n" + ex.ToString()); } else { MessageBox.Show(ex.ToString()); } } stopwatch = Stopwatch.StartNew(); }