What's wrong with my FolderBrowserDialog?
What's wrong with my FolderBrowserDialog?
Hi, I use the FolderBrowserDialog in installer class. However, when the dialog box is open, I did not see anywhere where a user can select a folder. It has just three buttons. Using MessageBox, I saw folder_browser_dialog.RootFolder = "personal". It does not looks like a path. What is the problem here Or FolderBrowserDialog cannot be used in installer class Please help me. Many many thanks. Below is the code. FolderBrowserDialog folder_browser_dialog =
new System.Windows.Forms.FolderBrowserDialog(); folder_browser_dialog.Description = "Select the directory that you want to use to create tickler letters.";
folder_browser_dialog.RootFolder = Environment.SpecialFolder.Personal;
MessageBox.Show(folder_browser_dialog.RootFolder.ToString(), "");
DialogResult result = folder_browser_dialog.ShowDialog();
if( result == DialogResult.OK ) folderName = folder_browser_dialog.SelectedPath;
What's wrong with my FolderBrowserDialog?
sara8dev
From Visual C# Express MSDN:
========
New threads are initialized as ApartmentState.MTA if their apartment state has not been set before they are started. Apartment state must be set before a thread is started.
The main application thread is initialized to ApartmentState.MTA by default. The only way to set the apartment state of the main application thread to ApartmentState.STA is to apply the STAThreadAttribute attribute to the entry point method.
The SetApartmentState method, along with the GetApartmentState method and the TrySetApartmentState method, replaces the ApartmentState property.
==========
I did set the atribute for the Main function like this:
[STAThread]
public static void Main(){....}
and it worked Ok with folder_browser_dialog.ShowDialog(); without having to create a special thread just for the fun of displaing this dialog.
I did some tests and seemed to work ok with multiple threads, but I would apreciate a more adviced voice...But does setting this attribute for the Main() funtion affect in any way the capacity of my app to work with multiple threads
James Kieran Murphy
icpenguins
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=125360&SiteID=1