Check if a file is read-only 
Author Message
 Check if a file is read-only

I would like to know how to determine whether a file is read-only via
VB.Net. I have tried using the FileInfo.Attributes property, but to no
avail. Thanks in advance for any help.

Kory



Mon, 07 Feb 2005 05:24:26 GMT  
 Check if a file is read-only
This should do the trick. The .Attributes property is an integer with bits
set corresponding to file attributes, so you need to use And to mask the
bit(s) you want

Public Function IsFileReadOnly(ByVal file As String) As Boolean

Dim isReadOnly As Boolean

isReadOnly = System.IO.File.GetAttributes(file) And
IO.FileAttributes.ReadOnly

Return isReadOnly

End Function

This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> I would like to know how to determine whether a file is read-only via
> VB.Net. I have tried using the FileInfo.Attributes property, but to no
> avail. Thanks in advance for any help.

> Kory



Mon, 07 Feb 2005 05:36:08 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to check if file is read-only?

2. How to check if file is read-only?

3. How to check if file is read-only?

4. Reading files from a zip file (Just reading the filenames, not unzipping or zipping)

5. VB3 Binary FILES READ READ READ

6. I am trying to update a record, i am not using data control

7. I am learning VB.NET and am wondering....

8. I am trying to update a record, i am not using data control

9. How to read from a file on a read-only volume

10. Check DLL-File (Exist DLL-File?)

11. Check mail subject, mark as read, delete - How?

12. Checking if Normal.dot is read-only

 

 
Powered by phpBB® Forum Software