[RESOLVED] How to open a folder under mac lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- pasquale · 2012-03-24 19:50 Hi, everybody. Given a path to a certain folder, I would like to be able to open it. Unfortunately the following code does not work: Code: [Select]procedure TfrmAttachFolder.cmdOpenFolderClick(Sender: TObject);   var   MyFolder:String; begin   MyFolder := Trim(txtFolderPath.Text);   SelectDirectory('Selected folder:', '', MyFolder); end;  In fact, using the code above, the folder window shows the last selected folder, not the one indicated in the text box. Any help will be appreciated. ---------------------------------------------------------------------- pasquale · 2012-03-25 07:46 I have realized that my approach is wrong. In fact what I need is to open a folder window not in order to select a file or folder and import its path but in order to launch a file which is inside the folder. Unfortunately, the code I posted only allows you to select a folder path and prevents you from opening a file from the window which pops up. While I have no problems selecting and retrieving a folder path, I don't know how to open a folder in order to have access to the files it contains and launch them. Do you know how to do that? Thanks in advance. ---------------------------------------------------------------------- BigChimp · 2012-03-25 07:56 Search the wiki; I think the article on executing external programs might help... Also, there's an article on OSX programming and one on platform independent programming/multiplatform programming that illustrate some concepts... ---------------------------------------------------------------------- pasquale · 2012-03-25 09:04 Thanks for your reply. I've just taken a look at the Wiki page about how to launch external programs but, unless I missed something, there seems to be nothing about opening a folder situated in a specific path. In Windows a function like that only takes a line of code, but I can't find the equivalent for Mac of the following code: Code: [Select]   ShellExecute(0, nil, PChar(myFolderPath), nil, nil, 1); The equivalent Shell('open myFolderPath') of the Unix class does not open the folder. When I execute the code, nothing happens. ---------------------------------------------------------------------- pasquale · 2012-03-25 09:22 My mistake! The Shell function I used did not manage the spaces in the folder path. That's why it didn't work. For those of you who are interested, this is the correct code to use to open a folder window: Code: [Select]procedure TfrmAttachFolder.cmdOpenFolderPathClick(Sender: TObject);   var   MyFolder:String; begin   MyFolder := Trim(txtFolderPath.Text);   Shell('open "' + MyFolder + '"'); end;