ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Testing if Directory has read/write access (https://www.excelbanter.com/excel-programming/381003-re-testing-if-directory-has-read-write-access.html)

Chip Pearson

Testing if Directory has read/write access
 
Try something like the following:

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

You can also do it with the Scripting.FileSystemObject

Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.GetFolder("\\DellLapTop\MainDrive\Temp").Attri butes And 1 Then
Debug.Print "Folder is read only"
Else
Debug.Print "Folder is read-write"
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Nigel RS" wrote in message
...
What is the best method of testing if a directory has read and write
access?

I have an application that saves files to a network server, I want to test
that the user on opening the application (from a local drive) has read or
read/write access to the remote server directory.

Thanks





All times are GMT +1. The time now is 01:58 PM.

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