diff --git a/mRemoteNG/App/ProgramRoot.cs b/mRemoteNG/App/ProgramRoot.cs
index c5891894..29023244 100644
--- a/mRemoteNG/App/ProgramRoot.cs
+++ b/mRemoteNG/App/ProgramRoot.cs
@@ -21,6 +21,12 @@ namespace mRemoteNG.App
[STAThread]
public static void Main(string[] args)
{
+ /*
+ * Temporarily disable LocalSettingsManager initialization at startup
+ * due to unfinished implementation causing build errors.
+ * Uncomment if needed in your local repo.
+ */
+ /*
/*var settingsManager = new LocalSettingsManager();
// Check if the database exists
diff --git a/mRemoteNG/UI/Forms/OptionsPages/NotificationsPage.cs b/mRemoteNG/UI/Forms/OptionsPages/NotificationsPage.cs
index 159dee05..7a40c08d 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/NotificationsPage.cs
+++ b/mRemoteNG/UI/Forms/OptionsPages/NotificationsPage.cs
@@ -155,8 +155,15 @@ namespace mRemoteNG.UI.Forms.OptionsPages
private void buttonOpenLogFile_Click(object sender, System.EventArgs e)
{
- if (Path.GetExtension(textBoxLogPath.Text) == ".log")
- Process.Start(textBoxLogPath.Text);
+ string logFile = textBoxLogPath.Text;
+ bool doesExist = File.Exists(logFile);
+
+ if (doesExist && OpenLogAssociated(logFile))
+ return;
+ else if (doesExist && OpenLogNotepad(logFile))
+ return;
+
+ OpenLogLocation(logFile);
}
private void chkLogToCurrentDir_CheckedChanged(object sender, System.EventArgs e)
@@ -165,5 +172,71 @@ namespace mRemoteNG.UI.Forms.OptionsPages
buttonRestoreDefaultLogPath.Enabled = !chkLogToCurrentDir.Checked;
textBoxLogPath.Text = Logger.DefaultLogPath;
}
+
+ #region Privat Methods to Open Logfile
+
+ ///
+ /// Attempts to open a file using the default application associated with its file type.
+ ///
+ /// The path of the file to be opened.
+ /// True if the operation was successful; otherwise, false.
+ private static bool OpenLogAssociated(string path)
+ {
+ try
+ {
+ // Open the file using the default application associated with its file type based on the user's preference
+ Process.Start(path);
+ return true;
+ }
+ catch
+ {
+ // If necessary, the error can be logged here.
+ return false;
+ }
+ }
+
+ ///
+ /// Attempts to open a file in Notepad, the default text editor on Windows systems.
+ ///
+ /// The path of the file to be opened in Notepad.
+ /// True if the operation was successful; otherwise, false.
+ private static bool OpenLogNotepad(string path)
+ {
+ try
+ {
+ // Open it in "Notepad" (Windows default editor).
+ // Usually available on all Windows systems
+ Process.Start("notepad.exe", path);
+ return true;
+ }
+ catch
+ {
+ // If necessary, the error can be logged here.
+ return false;
+ }
+ }
+
+ ///
+ /// Attempts to open the location of a specified file in Windows Explorer.
+ ///
+ /// The path of the file whose location needs to be opened.
+ /// True if the operation was successful; otherwise, false.
+ private static bool OpenLogLocation(string path)
+ {
+ try
+ {
+ /// when all fails open filelocation to logfile...
+ // Open Windows Explorer to the directory containing the file
+ Process.Start("explorer.exe", $"/select,\"{path}\"");
+ return true;
+ }
+ catch
+ {
+ // If necessary, the error can be logged here.
+ return false;
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/mRemoteNGTests/App/UpdaterTests.cs b/mRemoteNGTests/App/UpdaterTests.cs
index c4c01c7a..80ee0914 100644
--- a/mRemoteNGTests/App/UpdaterTests.cs
+++ b/mRemoteNGTests/App/UpdaterTests.cs
@@ -9,75 +9,59 @@ namespace mRemoteNGTests.App;
[TestFixture]
public class UpdaterTests
{
+ private readonly Version TestApplicationVersion = new("1.0.0.0");
+
[Test]
public void UpdateStableChannel()
{
- GeneralAppInfo.ApplicationVersion = "1.0.0.0";
var CurrentUpdateInfo = UpdateInfo.FromString(Resources.update);
Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True);
- Version v;
- Version.TryParse(GeneralAppInfo.ApplicationVersion, out v);
- var IsNewer = CurrentUpdateInfo.Version > v;
+ bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion;
Assert.That(IsNewer, Is.True);
}
[Test]
public void UpdateBetaChannel()
{
- GeneralAppInfo.ApplicationVersion = "1.0.0.0";
var CurrentUpdateInfo = UpdateInfo.FromString(Resources.beta_update);
Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True);
- Version v;
- Version.TryParse(GeneralAppInfo.ApplicationVersion, out v);
- var IsNewer = CurrentUpdateInfo.Version > v;
+ bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion;
Assert.That(IsNewer, Is.True);
}
[Test]
public void UpdateDevChannel()
{
- GeneralAppInfo.ApplicationVersion = "1.0.0.0";
var CurrentUpdateInfo = UpdateInfo.FromString(Resources.dev_update);
Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True);
- Version v;
- Version.TryParse(GeneralAppInfo.ApplicationVersion, out v);
- var IsNewer = CurrentUpdateInfo.Version > v;
+ bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion;
Assert.That(IsNewer, Is.True);
}
[Test]
public void UpdateStablePortableChannel()
{
- GeneralAppInfo.ApplicationVersion = "1.0.0.0";
var CurrentUpdateInfo = UpdateInfo.FromString(Resources.update_portable);
Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True);
- Version v;
- Version.TryParse(GeneralAppInfo.ApplicationVersion, out v);
- var IsNewer = CurrentUpdateInfo.Version > v;
+ bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion;
Assert.That(IsNewer, Is.True);
}
[Test]
public void UpdateBetaPortableChannel()
{
- GeneralAppInfo.ApplicationVersion = "1.0.0.0";
var CurrentUpdateInfo = UpdateInfo.FromString(Resources.beta_update_portable);
Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True);
- Version v;
- Version.TryParse(GeneralAppInfo.ApplicationVersion, out v);
- var IsNewer = CurrentUpdateInfo.Version > v;
+ bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion;
Assert.That(IsNewer, Is.True);
}
[Test]
public void UpdateDevPortableChannel()
{
- GeneralAppInfo.ApplicationVersion = "1.0.0.0";
var CurrentUpdateInfo = UpdateInfo.FromString(Resources.dev_update_portable);
Assert.That(CurrentUpdateInfo.CheckIfValid(), Is.True);
- Version v;
- Version.TryParse(GeneralAppInfo.ApplicationVersion, out v);
- var IsNewer = CurrentUpdateInfo.Version > v;
+ bool IsNewer = CurrentUpdateInfo.Version > TestApplicationVersion;
Assert.That(IsNewer, Is.True);
}
}
\ No newline at end of file