保存代码如下
Dim savefile1 As New SaveFileDialog
savefile1.DefaultExt = "*.txt "
savefile1.Filter = "text Files|*.txt "
If (savefile1.ShowDialog() = System.Windows.Forms.DialogResult.OK) _
And (savefile1.FileName.Length) > 0 Then
Dim savemessage As New System.IO.StreamWriter(savefile1.FileName, True)
Try
savemessage.WriteLine(Label1.Text + ": ")
savemessage.WriteLine(TextBox1.Text)
savemessage.WriteLine()
savemessage.WriteLine(Label2.Text + ": ")
savemessage.WriteLine(TextBox2.Text)
savemessage.WriteLine(Label3.Text + ": ")
savemessage.WriteLine(TextBox3.Text)
Catch
Throw
Finally
savemessage.Close()
End Try
End If
打开代码如下:
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then
RichTextBox1.LoadFile(OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)
End If
请问是不是我保存和打开存在问题,如果是应该如何修改打开代码,请详细说明谢谢!!可加分!