alper
alper

Reputation: 153

How To Run A Process Command on Mac?

I'm trying to practice this Process class but it's been a flop since I could not figure out how to write the filenames and the paths correctly.

This is what I'm trying out but everytime I get the same error: Unhandled exception. System.ComponentModel.Win32Exception (2): No such file or directory

Process.Start("/Applications/Utilities/TextEdit.app/Contents/MacOS/TextEdit");

I tried different paths which were not much different from this one, but as I said idk what to do about this.

Do you know what's the accurate way of doing that?

Upvotes: 0

Views: 727

Answers (1)

persian-theme
persian-theme

Reputation: 6638

please use this code :

using (Process myProcess = new Process())
{
    myProcess.StartInfo.UseShellExecute = true;
    myProcess.StartInfo.FileName = fileName;
    myProcess.StartInfo.CreateNoWindow = false;
    myProcess.Start();
}

Upvotes: 1

Related Questions