hilson
asked on
Browse for Folder in C#
Has anyone managed to use BrowseForFolder in C# WITH initial folder selection. I can get the dialog to come up in a number of different ways (using old API / new .Net (framework support) code) however i cant get the initial folder selection working. I've implemented a callback for the purposes of sending the BFFM_SETSELECTIONA message to the dialog but it seems to have no effect. (I know I'm sending to the dialog because I can send BFFM_ENABLEOK to enable / disable the OK button). The problem seems to lie with translating my path string into the lparam parameter for BFFM_SETSELECTIONA.
ASKER
Thanks - but i dont want a file open dialog - i am asking the user to select a folder - so i just want the browseforfolder type dialog in which the user selects a folder only - they dont open a file in a specified folder.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for that - I had high hopes until I realised that the method it uses to take a folder path and convert it into a PIDL (for use by the callback fn) is only available in version 6.0 of shell32.dll - which is for windows XP. i wonder whether this version works on earlier o/s's?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you have to set the InitialDirectory property before showing the dialog:
OpenFileDialog dlg = new OpenFileDialog();
dlg.InitialDirectory = "C:\anywhere";
dlg.ShowDialog();