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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HOWTO: Start FolderBrowser in a non-special folder

Thread ID:

Created:

Updated:

Platform:

Replies:

6309 Aug 8,2003 05:45 AM Oct 13,2005 04:57 AM Windows Forms 5
loading
Tags: Tools
Eric Duesing
Asked On August 8, 2003 05:45 AM

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 06:14 AM

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 08:21 AM

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 05:43 PM

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 11:52 AM

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 04:57 AM

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.

CONFIRMATION

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.

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

;