FilePath = .FileName
End With
' Dim MyStreamRead As IO.StreamReader
' MyStreamRead = IO.File.OpenText(FilePath)
'Dim MyReceiver As String
'MyReceiver = MyStreamRead.ReadLine()
'While Not MyReceiver Is Nothing
'Me.TxtListen.AppendText(MyReceiver & ControlChars.CrLf)
'MyReceiver = MyStreamRead.ReadLine()
'End While
'MyStreamRead.Close()
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText(FilePath,System.Text.Encoding.Default)
TxtListen.Text = fileReader
End Sub
4) “保存”按钮单击事件代码
Private Sub BtSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtSave.Click
‘保存听写记录ToolStripMenuItem.Click
Dim FilePath As String
If Me.TxtListen.Text Is Nothing Then
MsgBox("当前听写区为空", MsgBoxStyle.OkOnly, "PC复读机")
Exit Sub
Else
SaveFileDialog1.ShowDialog()
SaveFileDialog1.Title = "保存填写记录"
SaveFileDialog1.CheckFileExists = False
SaveFileDialog1.CheckPathExists = True
SaveFileDialog1.Filter = "文本文件(*.txt)|*.txt"
FilePath = SaveFileDialog1.FileName
' With Me.SaveFileDialog1
'.Title = "保存填写记录"
' .CheckFileExists = False
' .CheckPathExists = True
' .Filter = "文本文件(*.txt)|*.txt"
' ' If ShowDialog() = Windows.Forms.DialogResult.Cancel Then
' ' Exit Sub
|