We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HOWTO: Start FolderBrowser in a non-special folder

Thread ID:





6309 Aug 8,2003 09:45 AM UTC Oct 13,2005 08:57 AM UTC WinForms 5
Tags: Tools
Eric Duesing
Asked On August 8, 2003 09:45 AM UTC

The FolderBrowser control can only be started in one of the predefined "special" folders. I wanted it to start in the current folder. Here is an example of how to do that: First, add a FolderBrowserCallback event handler to the FolderBrowser object. Then add the following code specifying the directory you want the folder to open: using System.Runtime.InteropServices; /*...*/ [DllImport("user32.dll",CharSet=CharSet.Unicode)] public static extern UInt32 SendMessage( IntPtr hWnd, UInt32 Msg, UInt32 wParam, IntPtr lParam); private void folderBrowser1_FolderBrowserCallback(object sender, Syncfusion.Windows.Forms.FolderBrowserCallbackEventArgs e) { if (e.FolderBrowserMessage==FolderBrowserMessage.Initialized) { const int BFFM_SETSELECTIONW=1127; SendMessage(e.Window.Handle,BFFM_SETSELECTIONW,1,Marshal.StringToHGlobalUni(@"c:\temp")); } }

Eric Duesing
Replied On August 8, 2003 10:14 AM UTC

Actually, that leaks, doesn't it. Instead of this: >SendMessage(e.Window.Handle,BFFM_SETSELECTIONW,1,Marshal.StringToHGlobalUni(@"c:\temp")); Try This: IntPtr p=Marshal.StringToHGlobalUni(@"c:\temp"); SendMessage(e.Window.Handle,BFFM_SETSELECTIONW,1,p); Marshal.FreeHGlobal(p);

Ramesh Praveen [Syncfusion]
Replied On August 11, 2003 12:21 PM UTC

Eric, Thanks for the info! That's a big help, it's been a frequent feature request. We will log this in our KB. -Praveen

Mark Emerson
Replied On August 26, 2003 09:43 PM UTC

Eric, Thank you! I've been wanting the ability to set a start location in the .NET world for sometime and hated using the old VB6 controls within wrappers. Excellent! Mark

Martin Schacher
Replied On October 11, 2005 03:52 PM UTC

Is there a workaround for vb to set the initial-directory? >Eric, > >Thank you! I''ve been wanting the ability to set a start location in the .NET world for sometime and hated using the old VB6 controls within wrappers. Excellent! > >Mark

Anupama Roy [Syncfusion]
Replied On October 13, 2005 08:57 AM UTC

Hi Martin, The following features for FolderBrowser have been added to our build internally. 1) Enumeration value FolderBrowserFolder.CustomStartLocation for Folder.StartLocation property. 2) FolderBrowserFolder.CustomStartLocation property for dialog root path. 3) FolderBrowserFolder.SelectLocation property for automatic scroll and highlight of desired path. Which version of Syncfusion are you using now? Best Regards, Anu.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon