Capturing Unknown Subfolder Name

R

Roy Harrill

Hi All,

I'm trying to find a way to capture a string containing the pathname of a
folder's subfolder.

For example, assume the root directory has two subfolders, named
"mynewstuff" and "myoldstuff", but you (the programmer) don't know these
names ahead of time. What code would produce a string array containing (at
element 0) "c:\mynewstuff\" and (at element 1) "c:\myoldstuff"? My goal is
to create an array containing the pathnames of all the folders on the
computer (and network if present). This s/b fairly easy using a recursive
looping routine, starting with the root directory and drilling down getting
the name of each folder's immediate subfolder(s).

I thought about trying to use ChDir to somehow get to the subfolder and then
using CurDir to get the full path, but I can't use ChDir without a specific
subfolder path, which of course is what I'm seeking.

Application.FileSearch.SearchScopes possibly could help, but I can't
determine whether it would or not.

I know the Subfolders property of File System Objects in Windows Script is
just what I need, but I must avoid using FSO due to security concerns.

I would appreciate any help with VBA or Office (Excel) code that would
generate an unknown subfolder path string.

TIA.

Roy
 
T

Tim Williams

If you can use VBA you already have full access to the filesystem, so what's
the problem with using FSO ?

In this context its use has no impact on security.


Tim
 
R

Roy Harrill

Tim,
I'm not a security guru, but my understanding is that under some enterprise
IT policies, WSH/FSO may be disabled on user's PCs due to the ease by which
it can be used to spread viruses. So if I were planning on others using my
program, some of them couldn't do so if I required WSH/FSO.
Roy
 

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