using dir to get folder names

P

pjryan

I am using dir(path, vbdirectory) to return the names of folders and files,
but instead of getting the folder name, I am getting "." How can I remedy
this.

Thanks
 
D

Dave Peterson

Write your code to ignore it.

.. is the shortcut for the current directory
... is the shortcut for the parent directory

In some versions of windows, you can go up the path with more and more dots.
 
J

Jacob Skaria

MyPath = "c:\"
MyName = Dir(MyPath, vbDirectory)
Do While MyName <> ""
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
MsgBox(MyName)
End If
MyName = Dir()
Loop

If this post helps click Yes
 
P

pjryan

thanks - I know what the "." and ".." mean when listing directories and
folders, but it did not compute to me here! I did not let my loop continue
running to see what would come next. When "." showed up first, I panicked.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top