ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   quick list of directories.. (https://www.excelbanter.com/excel-programming/329495-quick-list-directories.html)

Mark

quick list of directories..
 
I'm looking for a quick way to get a list of directories.

I first tried this type of scheme from the Scripting.FileSystemObject 's

Set f = fs.getfolder(stDir)
Set fc = f.SubFolders

but that seems to run really slowly for any directory with a couple of
hundred subfolders.

I also tried the Dir function with the vbDirectory set as the attribute.

That gets the directories, but it gets them along with the files (ahah! I
think that will work for specifically what I'm doing now, now that I think
about it again).

But I'd still like to know a faster way to get only the subfolder names, if
someone knows one.

Thanks.

Harald Staff

quick list of directories..
 
Afaik Dir is as fast as it gets in Windows. See
http://www.dicks-blog.com/archives/2...attr-function/
for code.

HTH. Best wishes Harald

"mark" skrev i melding
...
I'm looking for a quick way to get a list of directories.

I first tried this type of scheme from the Scripting.FileSystemObject 's

Set f = fs.getfolder(stDir)
Set fc = f.SubFolders

but that seems to run really slowly for any directory with a couple of
hundred subfolders.

I also tried the Dir function with the vbDirectory set as the attribute.

That gets the directories, but it gets them along with the files (ahah!

I
think that will work for specifically what I'm doing now, now that I think
about it again).

But I'd still like to know a faster way to get only the subfolder names,

if
someone knows one.

Thanks.




Mark

quick list of directories..
 
Thanks, Harald.

I think "If GetAttr(sPath & sDirName) = vbDirectory " will do exactly what I
need, at a good speed. The f.Subfolders property I mentioned first was
unusably slow.

Thanks for your help.
Mark

"Harald Staff" wrote:

Afaik Dir is as fast as it gets in Windows. See
http://www.dicks-blog.com/archives/2...attr-function/
for code.




All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com