473,385 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

List the names of folders in a drive ??? or How to find folder names in a drive?

30
Hi

How to list the names of all the folders in a drive ????

OR

I have taken a Dir (directory list box) and text box. And using the timer, the selection of the the directories in the (directory list box) in a drive (Ex: E:\) moves top directory to last directory (using the List index property) automatically. So, when the selection selects a directory the path of the selected directory should be displayed in the text box. And when it moves down to the next directory it should display the next directory path in the text box.

I hope am clear with the above info.

Thanks in advance.
Aug 19 '07 #1
3 5904
pureenhanoi
175 100+
Hi

How to list the names of all the folders in a drive ????

OR

I have taken a Dir (directory list box) and text box. And using the timer, the selection of the the directories in the (directory list box) in a drive (Ex: E:\) moves top directory to last directory (using the List index property) automatically. So, when the selection selects a directory the path of the selected directory should be displayed in the text box. And when it moves down to the next directory it should display the next directory path in the text box.

I hope am clear with the above info.

Thanks in advance.
To get the current selected path from DirListBox, you can use the .List property
Expand|Select|Wrap|Line Numbers
  1. Private Sub Dir1_Change()
  2. Text1.Text = Dir1.List(Dir1.ListIndex)
  3. End Sub
  4.  
To show all sub-folder in the current path, you can use Dir$() function of VB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim fileName As String
  3. Dim path As String
  4. Dim attrib As VbFileAttribute
  5. attrib = vbDirectory
  6. path = "C:\"
  7. fileName = Dir$(path,attrib)
  8. While Len(filename)
  9.   List1.AddItem fileName
  10.   fileName = Dir$
  11. Wend
  12. End Sub
  13.  
Here List1 is a ListBox, used to display all folder from "C:\"
Change path= "C:\" to any folder that you want
Aug 20 '07 #2
kinnu
30
Thank you so much. Both methods are helpful and wonderfullllllll.
Aug 20 '07 #3
Killer42
8,435 Expert 8TB
Thanks pureenhanoi.

kinnu, just keep in mind that while the built-in Dir() function is certainly very quick and simple to use, the FileSystemObject model provides much more functionality. It's well worth learning about - look it up in the doco when you have some time.

In the meantime though, good ol' Dir() will do the job.
Aug 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: James Kunicki | last post by:
Hello, I would like to know if anyone as found a way to list a image next to a list box to indicate what type of drive (local or network) and a folder I would like to present in a user...
5
by: George | last post by:
VB.net 2003 standard, XP windows home edition. Installed first application OK today. When I removed the application via Control Panel, there were no problems and the app folders were deleted. ...
22
by: rtilley | last post by:
# Spaces are present before and after the XXX filename = ' XXX ' new_filename = filename.strip() if new_filename != filename: print filename Macs allow these spaces in file and folder...
2
by: Regnab | last post by:
I'm looking for code that I can use to return the names of sub folders which exist in a folder. The end goal is to be able to then use the DIR(*) function to return the name of all files in each...
4
by: manontheedge | last post by:
I'm using Dir() which is built into VB6, in order to go to a folder and find the names of all the files in that folder. It's extremely simple. BUT, it won't tell me what folders are in the...
8
by: 7effrey | last post by:
Hi Does anyone know how to make a script that list the folders in a specific directory, but when the list is made it must be possible to click on it like a link so people can be redirected, but...
2
by: pbrown | last post by:
Hey All, My problem appears to be pretty simple. I need a way of listing all the folders that exist in a certain directory. By all the folders, I mean ALL the folders; any file folder that exists...
2
by: Mike P | last post by:
I need to find all the folders at a certain location, and then once I have this list of folders I need to add some of them to a collection and then show the names of those folders on screen (there...
3
Chrisjc
by: Chrisjc | last post by:
So here is the issue at hand. I have several domains across a WAN environment and just recently I started noticing something odd between all my Domain Controllers. Every Site in my company has a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.