How to modify this code to make my StreamWriter file READ ONLY
Does anyone have a clue as to how to modify the code below so the file is saved to the Hard Disk with the “Read Only” attribute.
Code:
' This Sub uses a StreamWriter object to create a .txt file
'With Text coming out of the Serial port. The name of the file
'is composed of the Machine Serial#, Date and Time String (time ‘includes seconds)
Sub SerialCopyWriter()
Dim myStreamWriter As StreamWriter
Dim myPath As String = "..\Readings Backup\"
Dim myMachine As Integer = 3035
Dim myName As String = myMachine & "+" & Now.Month & "_" & Now.Day & "_" _
& Now.Year.ToString & "+" & Now.Hour & "_" & Now.Minute & "_" & Now.Second & ".txt"
Dim myFileName As String = myPath + myName
'Resulting file name 3035+8_2_2003+7_38_41
Try
' Create the StreamWriter
myStreamWriter = File.CreateText(myFileName)
myStreamWriter.Write(txtFileText.Text)
myStreamWriter.Flush()
Catch exc As Exception
' Show the error to the user.
MsgBox("A copy of the serial port Data-Reading for this Coffee Machine could not be Created:" + _
vbCrLf + vbCrLf + "Exception: " + exc.Message)
Finally
If Not myStreamWriter Is Nothing Then
myStreamWriter.Close()
End If
End Try
End Sub