Results 1 to 10 of 10

Thread: Accessing Desktop Folder from Code?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Accessing Desktop Folder from Code?

    I'm writing an application in which the user can select files from a directory structure. My problem is that I only have the C: drive and a D: drive. I also need to be able to provide access to the "Desktop" directory structure. How can I add the Desktop directory structure to a "Directory" control? I basically need something like Windows Explorer.

    Thanks,
    Blake

  2. #2

  3. #3
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Accessing Desktop Folder from Code?

    Another way:
    My.Computer.FileSystem.SpecialDirectories.Desktop
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Accessing Desktop Folder from Code?

    How do I include the "Desktop" structure in the DirectoryBox control?
    Blake

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Accessing Desktop Folder from Code?

    Quote Originally Posted by blakemckenna View Post
    How do I include the "Desktop" structure in the DirectoryBox control?

    What is a " DirectoryBox control"?

    Did you mean this

    Code:
            Dim ofd As New OpenFileDialog
            ofd.Multiselect = True
            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
    
            Dim dr As DialogResult = ofd.ShowDialog
            If dr = DialogResult.OK Then
                For Each s As String In ofd.FileNames
                    Debug.WriteLine(s)
                Next
            End If
    Last edited by dbasnett; Dec 29th, 2010 at 03:29 PM.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Accessing Desktop Folder from Code?

    My bad...I meant the "DirectoryListBox" control.
    Blake

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Accessing Desktop Folder from Code?

    Vb6?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Accessing Desktop Folder from Code?

    Yes...it originated in earlier versions of VB but you can include the namespace that contains the control. The namespace is "Microsoft.VisualBasic.Compatibility.VB6". Hope that helps!
    Blake

  9. #9
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Accessing Desktop Folder from Code?

    Oh. I got this far

    Code:
            Dim foo As New Microsoft.VisualBasic.Compatibility.VB6.DirListBox
            'Warning(1) Microsoft.VisualBasic.Compatibility.VB6.DirListBox' is obsolete: 
            'Microsoft.VisualBasic.Compatibility.* classes are obsolete and supported within 32 bit processes only. http://go.microsoft.com/fwlink/?linkid=160862'.	C:\Users\dbasnett\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb	11	24	WindowsApplication1
    and stopped.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Accessing Desktop Folder from Code?

    Well...you can also add the control to the project on the toolbox. Look at the attached screenshot. Hope that helps!
    Blake

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