Try to open file if hyper link does not contain a valid URL

This commit is contained in:
Stone_Red
2024-06-04 16:19:36 +02:00
parent 551bb2ad90
commit 27244ba2a3
@@ -1,6 +1,8 @@
using Markdowser.Utilities;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Input;
namespace Markdowser.Commands;
@@ -32,6 +34,22 @@ public class HyperlinkCommand : ICommand
{
GlobalState.CurrentTabState.Url = new Uri(new Uri(GlobalState.CurrentTabState.Url), url).ToString();
}
else if (File.Exists(url))
{
ProcessStartInfo processStartInfo = new()
{
FileName = url,
UseShellExecute = true
};
try
{
_ = Process.Start(processStartInfo);
}
catch (Exception ex)
{
GlobalState.Logger.LogError(ex.Message);
}
}
else
{
GlobalState.Logger.LogDebug($"Invalid URL: {url}");