Spara enkelt ner i textfil – VB.net

Så här sparar man enkelt ner något i txt-filer i VB.net

 

 

Public Function SaveTextToFile(ByVal strData As String, _

ByVal FullPath As String, _

Optional ByVal ErrInfo As String = “”) As Boolean

Dim Contents As String

Dim bAns As Boolean = False

Dim objReader As StreamWriter

Try

objReader = New StreamWriter(FullPath)

objReader.Write(strData)

objReader.Close()

bAns = True

Catch Ex As Exception

ErrInfo = Ex.Message

End Try

Return bAns

End Function