Easy Way to Check File Privileges?

E

Eric G

I am recursively looping through a folder hierarchy, and then through all the
files in each folder. As part of my process, I need to check my ability to
open each of the files (i.e. do I have the correct permission) for read or
read/write. Is there a quick way to do this in VBA without actually trying
to open each file?

Here is some fragmentary code to illustrate my use of variables (from the
NG, of course):

Dim fso As Scripting.FileSystemObject
Dim oDir As Folder
Dim fSubDir As Folder ' Used for recursion...
Dim oFile As File

....

Set fso = CreateObject("Scripting.FileSystemObject")
Set oDir = fso.getfolder(strPath)

....

For Each oFile In fSubDir.Files
' check to see if I have "Read" or "Read/Write" permission for each
file
' and report those for which I don't
Next oFile

Thanks in advance,

Eric
 

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