Check if a file is read only Using VB.NET
In this article I describe how to check if a file is read only.
Check if a file is read only
The IsReadOnly property returns if a file is read only. The following code snippet returns true if a file is read only.
Imports System.IO
Module Module1
Sub Main()
Dim fileName As String = "C:\Temp\MaheshTXFI.txt"
Dim fi As New IO.FileInfo(fileName)
Dim exists As Boolean = fi.Exists
' File ReadOnly ?
Dim IsReadOnly As Boolean = fi.IsReadOnly
Console.WriteLine("Is ReadOnly: {0}", IsReadOnly)
Console.ReadLine()
End Sub
End Module
Output: