From 66726b87c7563521de59c880cefeb22501f6bfba Mon Sep 17 00:00:00 2001 From: Vichingo455 <59311016+Vichingo455@users.noreply.github.com> Date: Mon, 7 Mar 2022 17:19:31 +0100 Subject: [PATCH] Command line switches --- Notepad/Form1.cs | 5 ++++- Notepad/Program.cs | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Notepad/Form1.cs b/Notepad/Form1.cs index 8920408..05300b3 100644 --- a/Notepad/Form1.cs +++ b/Notepad/Form1.cs @@ -253,7 +253,10 @@ namespace Notepad private void Form1_Load(object sender, EventArgs e) { - + if (File.Exists(Global.savefilename)) + { + text_area.Text = File.ReadAllText(Global.savefilename); + } } private void aboutWindowsToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/Notepad/Program.cs b/Notepad/Program.cs index b34d976..8f82be2 100644 --- a/Notepad/Program.cs +++ b/Notepad/Program.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using System.Web; using System.Diagnostics; +using System.IO; namespace Notepad { @@ -35,10 +36,18 @@ namespace Notepad /// Punto di ingresso principale dell'applicazione. /// [STAThread] - static void Main() + static void Main(string[] switches) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + if (switches.Length == 1) + { + string arg = switches[0].Trim(); + if (File.Exists(arg)) + { + Global.savefilename = arg; + } + } Application.Run(new Form1()); } }