
Untitled
By: a guest on
Apr 27th, 2010 | syntax:
VB.NET | size: 1.49 KB | hits: 106 | expires: Never
Imports System.IO
Public Class Form1
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim blOK As Boolean = True
If txtName.Text.Trim() = String.Empty Then
epName.SetError(txtName, "You cannot leave this blank.")
blOK = False
End If
If txtURL.Text.Trim() = String.Empty Then
epURL.SetError(txtURL, "You cannot laeve this blank.")
blOK = False
End If
If blOK Then
sfdData.Filter = "Text Files *.txt|All files *.*"
sfdData.OverwritePrompt = False
sfdData.RestoreDirectory = True
Dim drSave As DialogResult = sfdData.ShowDialog()
If drSave = DialogResult.OK Then
Dim output As String = String.Format("{0}|{1}", txtName.Text, txtURL.Text)
Dim filename As String = sfdData.FileName
If File.Exists(filename) Then
Dim stream_writer As StreamWriter
stream_writer = File.AppendText(filename)
stream_writer.WriteLine(output)
stream_writer.Close()
Else
Dim stream_writer As StreamWriter
stream_writer = File.CreateText(filename)
stream_writer.WriteLine(output)
stream_writer.Close()
End If
End If
End If
End Sub
End Class