|
-
Feb 13th, 2000, 09:24 PM
#1
I'm using a loop containing:
Dir$("*.*", vbDirectory)
to get a list of directories in the current folder, but it's also returning all the files in the current folder (which I don't want!!)
Any ideas why? (And more to the point...how to stop it!!)
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ: 31422892
Web Site: My Home Page
AKA: ...::: The Fragmeinster :::... (On Quake 3 World Forums)
Sorry about my English, but my Scouse is dead good!
-
Feb 13th, 2000, 10:16 PM
#2
Frenzied Member
Try
Dir$("*.", vbDirectory)
to get the directories only - this works in DOS (I've never tried it in VB!)
Note: In DOS at least, this returns any files/folders with no extension (normally this is just the folders but you can sometimes get a few files turning up as well)
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
-
Feb 13th, 2000, 10:16 PM
#3
Frenzied Member
Try
Dir$("*.", vbDirectory)
to get the directories only - this works in DOS (I've never tried it in VB!)
Note: In DOS at least, this returns any files/folders with no extension (normally this is just the folders but you can sometimes get a few files turning up as well)
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
-
Feb 13th, 2000, 10:17 PM
#4
Frenzied Member
Try
Dir$("*.", vbDirectory)
to get the directories only - this works in DOS (I've never tried it in VB!)
Note: In DOS at least, this returns any files/folders with no extension (normally this is just the folders but you can sometimes get a few files turning up as well)
------------------
Mark "Buzby" Beeton
VB Developer
[email protected]
-
Feb 14th, 2000, 01:05 AM
#5
Sorry, Azzmodan, your method still returns all the files in the specified path - as well as the folders. I ONLY want the folders!!
Alternatively...is there a RELIABLE way to determine if a path points to a file or folder...I could filter them out that way...
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ: 31422892
Web Site: My Home Page
AKA: ...::: The Fragmeinster :::... (On Quake 3 World Forums)
Sorry about my English, but my Scouse is dead good!
-
Feb 14th, 2000, 01:13 AM
#6
I've just had a look at the help file and it says that "vbDirectory":
Specifies directories or folders in addition to files with no attributes.
How can I stop Dir$ from returning "files with no attributes".
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ: 31422892
Web Site: My Home Page
AKA: ...::: The Fragmeinster :::... (On Quake 3 World Forums)
Sorry about my English, but my Scouse is dead good!
-
Feb 14th, 2000, 01:17 AM
#7
Hyperactive Member
Hi,
Might you be able to use something like this?
A DirListBox control displays directories and paths at run time. Use this control to display a hierarchical list of directories. You can create dialog boxes that, for example, enable a user to open a file from a list of files in all available directories.
Syntax
DirListBox
Remarks
Set the List, ListCount, and ListIndex properties to enable a user to access items in a list. If you also display the DriveListBox and FileListBox controls, you can write code to synchronize them with the DirListBox control and with each other.
Al.
------------------
A computer is a tool, not a toy.
<A HREF="mailto:[email protected]
[email protected]">[email protected]
[email protected]</A>
-
Feb 14th, 2000, 01:22 AM
#8
Fanatic Member
Try
Code:
Dir$("*.*", (vbDirectory) And (Not vbNormal))
I dunno if it will work, but it's worth a try 
------------------
r0ach(tm)
-
Feb 14th, 2000, 04:08 AM
#9
Nope, sorry...nice try though!! I considered using something like that already and neither mine nor yours worked. 
As for using a directory list box, I'd rather avoid this because the program is running as a CGI program on a web server...so it needs to be as small, fast and memory efficient as possible!
Any other ideas? Is there an API that returns only folders?
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ: 31422892
Web Site: My Home Page
AKA: ...::: The Fragmeinster :::... (On Quake 3 World Forums)
Sorry about my English, but my Scouse is dead good!
-
Feb 14th, 2000, 04:13 AM
#10
Can
Public Declare Function GetFileType Lib "kernel32" Alias "GetFileType" (ByVal hFile As Long) As Long
tell me if a file is really a folder? Dunno how to use this...?
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ: 31422892
Web Site: My Home Page
AKA: ...::: The Fragmeinster :::... (On Quake 3 World Forums)
Sorry about my English, but my Scouse is dead good!
-
Feb 14th, 2000, 12:16 PM
#11
Euh use, Dir("C:\",vbdirectory) for all Dir's in the specified dir.
If you use "*." you don't get any dir's with extensions(and some dir's have extensions)
------------------
Vincent van den Braken
EMail: [email protected]
ICQ: 15440110
Homepage: http://www.azzmodan.demon.nl
-
Feb 14th, 2000, 05:25 PM
#12
Come on! Help me out here! 
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ: 31422892
Web Site: My Home Page
AKA: ...::: The Fragmeinster :::... (On Quake 3 World Forums)
Sorry about my English, but my Scouse is dead good!
-
Feb 14th, 2000, 06:34 PM
#13
Hyperactive Member
Sorry, but this is just plain simple VB programming.. should be able to find it out yourself.. but anyway, this gave a nice listing of all my folders in the C:\Program Files\ folder:
Code:
Dim s As String
Dim sStartIn As String
sStartIn = "C:\Program Files\"
s = Dir$(sStartIn, vbDirectory)
Do While s <> ""
If s <> "." And s <> ".." Then
If (GetAttr(sStartIn & s) And vbDirectory) Then
Debug.Print s
End If
End If
s = Dir$()
Loop
-
Feb 14th, 2000, 07:48 PM
#14
Thanks!! An asnwer that works! 
I didn't even know the getattr function existed...silly me!
My directory listing looks much better now!
------------------
Matthew Ralston
E-Mail: [email protected]
ICQ: 31422892
Web Site: My Home Page
AKA: ...::: The Fragmeinster :::... (On Quake 3 World Forums)
Sorry about my English, but my Scouse is dead good!
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
|