version of .net + folder browser

  • Thread starter Thread starter juli jul
  • Start date Start date
J

juli jul

Hello ,I am working with
..Net Framework 1.1 - Version:1.1.4322
and Development Enviroment2003 - Version 7.1.3088.

Is this version of .Net supposed to have a normal folder browser or
might be that the version is the reason I don't have a normal folder
browser?
If not,which control could I use instead?
Thank you very much!
 
Juli Jul,

Did you try this one
{
FolderBrowserDialog fb = new FolderBrowserDialog();
fb.ShowDialog();
MessageBox.Show(fb.SelectedPath);
}

I thought that I told you in a previous version that the standart Net 1.1
version has a bug which is repared in Net SP1. However this it has to do
withouth that as well when your paths are shorter than 128 characters.

I hope this helps?

Cor
 
Define "normal folder browser". The options are the
System.Windows.Forms.FolderBrowserDialog or to use the SHBrowseForFolder
function in the Shell32.dll.

HTH

DalePres
 
Hello,
with the normal folder I mean the :
System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
I tried to do the ShowDialog() method and all I can see is still an
empty window with no folders to choose.
Could someone help? Thank you!
 
Juli,

Did you try my code snippet?

Direct in line, by instance in a load of the form.

Cor
 
Hello,
Yes I tried this code and still see an empty window ,the message box
which suppose to show the path to the folder is empty (no selected
path).
Is there some solution for it?
Thank you!
 
Hello,
Could you please explain how to use the STAThread and how do I implement
the folder browser with it?
Thank you!
 
Hi,

If my guess is correct. Change the attribute [MTAThread] to [STAThread] In
the Main function.

If you have to use MTAThread, the only way to show the folder browser is use
the SHBrowseForFolder function in the Shell32.dll.
Though this function doesn't support 'Make a new folder' button when you use
MTAThread.

The website http://www.netomatix.com/FolderBrowser.aspx might help you to
wrap the FolderBrower class.

Ping
 
Hello,
I tried to make a new project with only the folder browser in it and it
works there but inside mine project it doesn't.Is it possible that this
control can't be at the same form with some other control?
Are there some kind of sources with which I could implement the folder
browser some other way?
Thanks a lot!
 
Hi, Juli

To implement your own folder browser, That is a lot of work. personally I
don't think that is a good way to do.

What type is project? Windows Application? Please dobule check what
attributes applied to Main function.

Another way to identify if it is MTAThread problem. On your new test
project, change the STAThread to MTAThread; if you get the same result as
your project does, just change the attribute should fix your problem.

Help this helps
 
Hello,
Could you please tell me how to check those attributes in main,I tried
to read about it in the net bit somehow not sure how to do it?
Thank you very much!
 
Hi, Juli

I can give you 2 ways to check the COM threading model.

1. find your Main function, you might find there are attributes applied to
the Main function, usually it looks like
[STAThread]
static void Main()
{
...
}


2. If you are not able to get your Main function source (I presume the
source file is owned by somebody else), you still can get the current COM
threading model by calling ApartmentState in Thread class, it looks like

using System.Threading; // you have to add this namespace

ApartmentState state = Thread.CurrentThread.ApartmentState;
// you can set breakpoint here to check the value of state. or pop up a
message box to display it.


Add this code just before your call ShowDialog function, you will know what
COM threading model the FolderBrowser is running on?

Help this helps
 
The messagebox result was that I have a MTA attribute-what does that
mean and should I change it (and how) in order to see folders in
browser?
Thanks a lot!
 
You have to change the attribute in Main function, it should look like
[STAThread]
static void Main()
{
.....
}


find your Main function, you will notice that there is [MTAThread] attribute
just before Main function; Change it to STAThread, the FolderBrowser should
work. It is just like what I said at very beginning.

Help this helps
 
Hello,
I can't see the [MTAThread] before main. I saw its value by printing the
code which detereined the attribute. How can I access it?
Thank you very much!
 
Hello,
Thank you very very much!
The MTA attribute was my problem and now I can see folders.
 
Back
Top