ehout
asked on
read-only access
Hai,
I'm using the functions below to find some directory in which a user has write access. However, in a map with 50 subdirectories where the user only has write access to 5 of them I find the procedure to slow.
Does someone know a quicker way to check for write access to the sub maps?
(BTW, yes, most of the functions came out of VBA help files ;-) )
Function Make_List() As String
Dim MyPath As String, MyName As String, maplist As String
MyPath = "f:\data\"
MyName = Dir(MyPath, vbDirectory)
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
If check_access(MyPath & MyName & "\") Then maplist = maplist & "," & MyName
End If
End If
MyName = Dir
Loop
Make_List = Right(maplist, Len(maplist) - 1)
End Function
Private Function check_access(pad As String) As Boolean
On Error GoTo handler
Open pad & "TESTFILE" For Output As #1
Close #1
Kill pad & "TESTFILE"
check_access = True
Exit Function
handler:
check_access = False
End Function
Kind regards
I'm using the functions below to find some directory in which a user has write access. However, in a map with 50 subdirectories where the user only has write access to 5 of them I find the procedure to slow.
Does someone know a quicker way to check for write access to the sub maps?
(BTW, yes, most of the functions came out of VBA help files ;-) )
Function Make_List() As String
Dim MyPath As String, MyName As String, maplist As String
MyPath = "f:\data\"
MyName = Dir(MyPath, vbDirectory)
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
If check_access(MyPath & MyName & "\") Then maplist = maplist & "," & MyName
End If
End If
MyName = Dir
Loop
Make_List = Right(maplist, Len(maplist) - 1)
End Function
Private Function check_access(pad As String) As Boolean
On Error GoTo handler
Open pad & "TESTFILE" For Output As #1
Close #1
Kill pad & "TESTFILE"
check_access = True
Exit Function
handler:
check_access = False
End Function
Kind regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Indeed it seems to do the trick. However I'm not a hardcore programmer (though willing to learn). Could you or someone please tell me how to use that function?
The ntfs example seems a bit complex to me.