I have spent a few days researching directory traversing in VB 6.0. I have found that most use this kind of approach:
1: File_Name = Dir$(File_Path, vbDirectory)
2: Do While File_Name <> ""
3: File_Name = Dir$
4: Loop
It is then used in a recursive manner.
What I have found frustrating is that all the examples I find, don't work?
I think line 1 of the code above should return a pointer to a list of directory names? But instead it returns all items in the directory? What is the point of specifying vbDirectory?
Once I realized that everything is brought back (dir, files), I found that someone used this function to determine the type of item:
GetAttr(File_Path & File_Name) = X
Where X is a code for a type of attribute for a file.
In all the examples I found, all used vbDirectory as X (16).
I understand what is done here, but in testing I found the following to be valid values for directories (X):
8240
8241
8208
Am I in the correct thinking, or is there a better way? Also, if I am correct about this being the best way to do things:
1: File_Name = Dir$(File_Path, vbDirectory)
2: Do While File_Name <> ""
3: If GetAttr(File_Path & File_Name) = 8240 Or GetAttr(File_Path & File_Name) = 8241 Or GetAttr(File_Path & File_Name) = 8208 Then
4: ' Is Directory call function again
5: Else
6: ' Is File
7: end if
8: File_Name = Dir$
4: Loop
where can I find a lising of return values for getattr() function, and does this list change from OS to OS?
1: File_Name = Dir$(File_Path, vbDirectory)
2: Do While File_Name <> ""
3: File_Name = Dir$
4: Loop
It is then used in a recursive manner.
What I have found frustrating is that all the examples I find, don't work?
I think line 1 of the code above should return a pointer to a list of directory names? But instead it returns all items in the directory? What is the point of specifying vbDirectory?
Once I realized that everything is brought back (dir, files), I found that someone used this function to determine the type of item:
GetAttr(File_Path & File_Name) = X
Where X is a code for a type of attribute for a file.
In all the examples I found, all used vbDirectory as X (16).
I understand what is done here, but in testing I found the following to be valid values for directories (X):
8240
8241
8208
Am I in the correct thinking, or is there a better way? Also, if I am correct about this being the best way to do things:
1: File_Name = Dir$(File_Path, vbDirectory)
2: Do While File_Name <> ""
3: If GetAttr(File_Path & File_Name) = 8240 Or GetAttr(File_Path & File_Name) = 8241 Or GetAttr(File_Path & File_Name) = 8208 Then
4: ' Is Directory call function again
5: Else
6: ' Is File
7: end if
8: File_Name = Dir$
4: Loop
where can I find a lising of return values for getattr() function, and does this list change from OS to OS?