ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking for File/Directory Permissions (https://www.excelbanter.com/excel-programming/381248-checking-file-directory-permissions.html)

Nigel

Checking for File/Directory Permissions
 
Chip Pearson kindly provided the following code to check read/write access
attributes for files, which works great. How do I check for file and
directory permissions in an NTFS network file system?

In my company network I need to check if the user has full control or at
least modify permission to read/write and delete files and/or directories.
Before my VBA programs try to take specific actions.


' code from C Pearson Jan 2007
Dim Attr As Long
Attr = GetAttr("\\DellLapTop\MainDrive\Temp")
If Attr And vbReadOnly Then
Debug.Print "Folder is read-only"
Else
Debug.Print "Folder is read-write"
End If

--
Cheers
Nigel





NickHK

Checking for File/Directory Permissions
 
Nigel,
Short of just creating/modifying/deleting a temp file on the test path and
trapping for permission denied errors, there's the API route.

Maybe these will help:
http://vbnet.mvps.org/code/network/netfileenum.htm
http://vbnet.mvps.org/code/network/netsharecheck.htm

NickHK

"Nigel" wrote in message
...
Chip Pearson kindly provided the following code to check read/write access
attributes for files, which works great. How do I check for file and
directory permissions in an NTFS network file system?

In my company network I need to check if the user has full control or at
least modify permission to read/write and delete files and/or directories.
Before my VBA programs try to take specific actions.


' code from C Pearson Jan 2007
Dim Attr As Long
Attr = GetAttr("\\DellLapTop\MainDrive\Temp")
If Attr And vbReadOnly Then
Debug.Print "Folder is read-only"
Else
Debug.Print "Folder is read-write"
End If

--
Cheers
Nigel








All times are GMT +1. The time now is 03:06 AM.

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