how to display selected directory in browse folder dialog?

This is a discussion on how to display selected directory in browse folder dialog? within the C# Programming forums, part of the General Programming Boards category; Hi All I have a problem while creating the browse for folder dialogue box in c#. how to set or ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Question how to display selected directory in browse folder dialog?

    Hi All

    I have a problem while creating the browse for folder dialogue box in c#. how to set or display the complete path of selected directory in browse folder dialogue?

    Code:
    private void selectDirectory_Click(object sender, System.EventArgs e)
            {
                string path = "";
                FolderBrowserDialog fdlg = new FolderBrowserDialog();
                fdlg.ShowNewFolderButton = false;
                fdlg.Description = "Current Selection";
                fdlg.SelectedPath = @"c:\"; 
                //fdlg.RootFolder = Environment.SpecialFolder.Desktop;             fdlg.ShowDialog();
                DialogResult result = fdlg.ShowDialog();
    
               {
                    if (fdlg.ShowDialog() == DialogResult.OK)
                
    
                    MessageBox.Show(fdlg.SelectedPath);
                        
                }
    Please help me for a solution as while i run the code it doesnot show the complete path of the directory selected. it only shows the text display "Current Selection" in browse folder dialog.

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    85
    does your message box return the correct path when you display it ?

    MessageBox.Show(fdlg.SelectedPath);

    if it does then try

    fdlg.Description = fdlg.SelectedPath;

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Thumbs up

    hi deviousdexter


    thankyou for your quick reply. Yes, message box return the correct path when i display it . but i need the complete path of selected directory to be displayed in the place which shows text display "Current Selection" in browse folder dialog. so whenever i click the files\directories the selected path for that particular files\directories must be displayed on browse folderdialog.is it possible? pls help me.

  4. #4
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Question

    please see the image below. it shows a browse for folder dialog with buttons like "ok" , "cancel", "make newfolder". On the top of folder dialog a text message is displayed "Select the directory where your future configurations will be installed".

    So what i need is whenever i click the files or directories , for example (pls refer image) here directory name is "Fundamentals", when clicked by user, it must display the path of selected directory, which must be shown instead of the text message "Select the directory where your future configurations will be installed". So it should display the selected path as C:\ADOLessons\Fundamentals.

    Hope you understand ? Pls help me.
    Attached Images Attached Images  

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Write your own browser dialog?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    127
    hi magos

    how can i write my own browse folder dialog?any idea

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,333
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Question

    how to Display the selected path for Browse Folder Dialog??

  9. #9
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,639
    As far as I know, you can't. You can set that value before you open the dialog, but that's a built-in dialog that you don't have any real control over after it's opened.

  10. #10
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Question

    can i set the value before opening the browse folder dialog?if so, where do i set the value??any idea.

  11. #11
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,639
    The Description property, perhaps?

  12. #12
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Question

    The Description property will show only the "Current Selection". How can it show the selected path of the directory/files?

  13. #13
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Question

    Instead of displaying the selected path, can i display selected directory in browse folder dialog?

  14. #14
    Registered User
    Join Date
    Oct 2008
    Posts
    85
    i think what you are trying to do is not possible with an easy solution.

    If i gather rightly, what you want to do is modify the "Desciption" after the form is loaded and displayed.

    I dont know if you will be able to change that property once it has done this but someone may know better - they normally do
    Last edited by deviousdexter; 11-25-2008 at 11:33 AM.

  15. #15
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Enumerate all controls in the dialog, somehow find the one you want then change its Text attribute.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  2. User Choosing Directory Dialog Box
    By Macromatt in forum Windows Programming
    Replies: 4
    Last Post: 01-19-2002, 10:57 PM
  3. dialog box: open folder : how to?
    By toby1909 in forum C++ Programming
    Replies: 2
    Last Post: 01-16-2002, 04:18 AM
  4. create a dialog box to open folder: how to?
    By toby1909 in forum Windows Programming
    Replies: 5
    Last Post: 01-13-2002, 12:49 PM
  5. Dialog Display
    By CodeMonkey in forum Windows Programming
    Replies: 2
    Last Post: 11-20-2001, 04:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21