Working Directory MacOS App called from Terminal

David Lilley 6 Reputation points
2021-03-24T09:55:07.347+00:00

We have a MacOS App built with Xamarin and we are implementing a Cmd Line Mode to use the program.

Unfortunately we don't have the correct working directory

We can call the App via

cd ~/Desktop
/Applications/MyApp.app/Contents/MacOS/MyApp -args1 -arg2

So if there is arguments I don't call the UI.

However Environment.CurrentDirectory is always set to NSBundle location and not to the Desktop, Is there anyway to find the current working directory from a MacOS App, that in this case would be the desktop?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,296 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. LouisWaweru 1 Reputation point
    2022-04-14T03:32:02.24+00:00

    This works on on a Mac:

    string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

    System.Runtime

    0 comments No comments