|
-
Dec 29th, 2010, 11:00 AM
#1
Thread Starter
PowerPoster
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,
-
Dec 29th, 2010, 11:11 AM
#2
Re: Accessing Desktop Folder from Code?
Code:
Environment.SpecialFolder.Desktop
See MSDN for a coding example and other special folders.
BB
-
Dec 29th, 2010, 11:14 AM
#3
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
-
Dec 29th, 2010, 03:08 PM
#4
Thread Starter
PowerPoster
Re: Accessing Desktop Folder from Code?
How do I include the "Desktop" structure in the DirectoryBox control?
-
Dec 29th, 2010, 03:25 PM
#5
Re: Accessing Desktop Folder from Code?
 Originally Posted by blakemckenna
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.
-
Dec 29th, 2010, 03:29 PM
#6
Thread Starter
PowerPoster
Re: Accessing Desktop Folder from Code?
My bad...I meant the "DirectoryListBox" control.
-
Dec 29th, 2010, 03:34 PM
#7
Re: Accessing Desktop Folder from Code?
-
Dec 29th, 2010, 03:44 PM
#8
Thread Starter
PowerPoster
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!
-
Dec 29th, 2010, 04:54 PM
#9
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.
-
Dec 29th, 2010, 05:23 PM
#10
Thread Starter
PowerPoster
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|