Software Development : A dizzy job...keeping abreast and being competitive is a 24X7 involvement
Apr 26, 2004
Apr 25, 2004
Apr 23, 2004
Apr 18, 2004
Apr 11, 2004
Apr 10, 2004
Apr 7, 2004
The Code Project - What is .NET Remoting ? - VB.NET: "NET Remoting relies on System.Runtime.Serialization"
Apr 3, 2004
Apr 1, 2004
File IO
Private Sub btnReadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadFile.Click
Dim sContents As String
Dim sErr As String
sContents = GetFileContents(Application.StartupPath & "\medicareTheme.ini", sErr)
If sErr = "" Then
MessageBox.Show("File Contents: " & sContents)
Else
MessageBox.Show("Error retrieving file: " & sErr)
End If
End Sub
Private Sub btnWriteFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWriteFile.Click
Dim bAns As Boolean
Dim sErr As String
'Save to different file
bAns = SaveTextToFile(TextBox2.Text, Application.StartupPath & "\medicareTheme.ini", sErr)
If bAns Then
MessageBox.Show("Theme Saved!")
Else
MessageBox.Show("Error Saving File: " & sErr)
End If
End Sub
Public Function GetFileContents(ByVal FullPath As String, _
Optional ByRef ErrInfo As String = "") As String
Dim strContents As String
Dim objReader As StreamReader
Try
objReader = New StreamReader(FullPath)
strContents = objReader.ReadToEnd()
objReader.Close()
Return strContents
Catch Ex As Exception
ErrInfo = Ex.Message
End Try
End Function
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
Private Sub btnReadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadFile.Click
Dim sContents As String
Dim sErr As String
sContents = GetFileContents(Application.StartupPath & "\medicareTheme.ini", sErr)
If sErr = "" Then
MessageBox.Show("File Contents: " & sContents)
Else
MessageBox.Show("Error retrieving file: " & sErr)
End If
End Sub
Private Sub btnWriteFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWriteFile.Click
Dim bAns As Boolean
Dim sErr As String
'Save to different file
bAns = SaveTextToFile(TextBox2.Text, Application.StartupPath & "\medicareTheme.ini", sErr)
If bAns Then
MessageBox.Show("Theme Saved!")
Else
MessageBox.Show("Error Saving File: " & sErr)
End If
End Sub
Public Function GetFileContents(ByVal FullPath As String, _
Optional ByRef ErrInfo As String = "") As String
Dim strContents As String
Dim objReader As StreamReader
Try
objReader = New StreamReader(FullPath)
strContents = objReader.ReadToEnd()
objReader.Close()
Return strContents
Catch Ex As Exception
ErrInfo = Ex.Message
End Try
End Function
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
Subscribe to:
Posts (Atom)