StrataFrame Forum

How to determine if a folder is read-only...

http://forum.strataframe.net/Topic16094.aspx

By StarkMike - 5/2/2008

I cant seem to figure out how to determine if a folder is read-only through VB .NET. Any help? Thanks
By Edhy Rijo - 5/2/2008

Hi,

Try the following code:

Dim myDirectory As New System.IO.DirectoryInfo("C:\TEMP")

If myDirectory.Attributes = System.IO.FileAttributes.ReadOnly Then

     ' Add your code here.

End If

By StarkMike - 5/2/2008

Thanks!
By Greg McGuffey - 5/2/2008

The attributes property is a bitwise flag, so you actually want to use something like this:

Dim myDirectory As New System.IO.DirectoryInfo("C:\TEMP")

If (myDirectory.Attributes And System.IO.FileAttributes.ReadOnly) = System.IO.FileAttributes.ReadOnly Then

' Add your code here.

End If
By Trent L. Taylor - 5/5/2008

Yup...Greg nailed it! Smile