CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Error Message

  1. #1
    Join Date
    Feb 2009
    Posts
    192

    Error Message

    Hi,

    I have a button click on my form, when I click it I receive the following error;
    The folder Desktop cannot be used
    Please Choose another folder

    OK

    When I click OK,

    it opens My Documents, My computer then I can browse through the drives..

    We have restriction in my work place and cant open the desktop, therefore, I wish to change the code to go straight to my computer where all the drives can be seen..


    The code is:



    Code:
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim fbd As New FolderBrowserDialog
    
            If fbd.ShowDialog = DialogResult.OK Then
                Label2.Text = fbd.SelectedPath
            End If
        End Sub
    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Error Message

    The problem here is that Desktop is a Valid directory "C:\users\{username}\Desktop" however 'My computer' is not a valid path, but simply a shortcut... What you could do is set it to goto "C:\"

    Code:
    fbd.SelectedPath = "C:\"
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Feb 2009
    Posts
    192

    Re: Error Message

    Changed the code to:

    Code:
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim fbd As New FolderBrowserDialog
    
            fbd.SelectedPath = "C:\Documents amd Settings\AbdallahR\Application\"
    
            If fbd.ShowDialog = DialogResult.OK Then
                Label2.Text = fbd.SelectedPath
            End If
        End Sub
    Still received the same error..

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Error Message

    Quote Originally Posted by dr223 View Post
    Changed the code to: "C:\Documents amd Settings\AbdallahR\Application\"
    Still received the same error..
    I suggested that::
    Quote Originally Posted by GremlinSA View Post
    What you could do is set it to goto "C:\"
    BECAUSE::
    Quote Originally Posted by dr223 View Post
    We have restriction in my work place and cant open the desktop, therefore, I wish to change the code to go straight to my computer where all the drives can be seen..
    and then also it's
    Documents and Settings not 'Documents amd Settings'
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Error Message

    You can set the RootFolder instead which will give you your starting point when opened.
    for example to start in my documents
    Code:
    FB1.RootFolder = Environment.SpecialFolder.MyDocuments
    The advantage here is that this will work on XP, Vista and Windows 7 even though the my documents folder is in a different location.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Error Message

    Code:
    We have restriction in my work place and cant open the desktop,
    That would be a Network Administration problem... Contact System Administrator...

    It's probably a ROAMING profile on the server... Can you see your desktop on ANY pc? Then it is.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured