If I have a path to a file, eg. an existing application on my mac, How can I use C# to open that file?
For example, here's a path to terminal on Mac OS
/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal
I tried using this code below by compiling it to an exe through csc, then using mono to execute it.
namespace democonsole
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process.Start("/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal");
}
}
}
Terminal returned an error of
Unhandled Exception:
System.ComponentModel.Win32Exception (0x80004005): Cannot find the specified file
at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x00102] in <6de7aa624f1544329fc30bc179f3b197>:0
at System.Diagnostics.Process.Start () [0x00032] in <6de7aa624f1544329fc30bc179f3b197>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x0001b] in <6de7aa624f1544329fc30bc179f3b197>:0
at System.Diagnostics.Process.Start (System.String fileName) [0x00006] in <6de7aa624f1544329fc30bc179f3b197>:0
at democonsole.Program.Main (System.String[] args) [0x0000c] in <1d59817ec01e4193b472af562e50f6f2>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.ComponentModel.Win32Exception (0x80004005): Cannot find the specified file
at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x00102] in <6de7aa624f1544329fc30bc179f3b197>:0
at System.Diagnostics.Process.Start () [0x00032] in <6de7aa624f1544329fc30bc179f3b197>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x0001b] in <6de7aa624f1544329fc30bc179f3b197>:0
at System.Diagnostics.Process.Start (System.String fileName) [0x00006] in <6de7aa624f1544329fc30bc179f3b197>:0
at democonsole.Program.Main (System.String[] args) [0x0000c] in <1d59817ec01e4193b472af562e50f6f2>:0 ```