kirkd
New member
I am writing to a text file. The problem is, is that sometimes the file is going to be read only. How do I remove the ReadOnly attribute from the file before writing to it. Here is a code snippet. This piece of code will only write to the file if the file is not read only. I want to replace this code with the above request.Any help would be appreciated
If oFileAttributes.ReadOnly <> FileAttributes.ReadOnly Then
Dim fs As FileStream = File.Open(fileName, FileMode.Append, FileAccess.Write)
Dim sw As StreamWriter = New StreamWriter(fs)
sw.Write(strInfo.ToString())
sw.Close()
fs.Close()
End If
If oFileAttributes.ReadOnly <> FileAttributes.ReadOnly Then
Dim fs As FileStream = File.Open(fileName, FileMode.Append, FileAccess.Write)
Dim sw As StreamWriter = New StreamWriter(fs)
sw.Write(strInfo.ToString())
sw.Close()
fs.Close()
End If