-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathProgram.cs
40 lines (31 loc) · 1.1 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MyNotepad {
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var Main = new Main();
var CommandLine = Environment.CommandLine.Trim();
var Filename = (string)null;
if (CommandLine.StartsWith("\"")) {
var ClosingQuoteIndex = CommandLine.IndexOf('\"', 1);
if (ClosingQuoteIndex < (CommandLine.Length - 1)) {
Filename = CommandLine.Substring(ClosingQuoteIndex + 1).Trim();
}
} else {
var FirstSpaceIndex = CommandLine.IndexOf(' ', 1);
if (FirstSpaceIndex != -1) {
Filename = CommandLine.Substring(FirstSpaceIndex + 1).Trim();
}
}
if (Filename != null) {
Main.Open(Filename);
}
Application.Run(Main);
}
}
}