主题:为什么不要支持中文啊
为什么不要支持中文啊
麻烦看一下如下代码
Private Function GetInformation(ByVal strFileName As String) As String
Dim strInfo As String
strInfo = strFileName & " exsits" & vbCrLf & vbCrLf
strInfo &= "Created : " & File.GetCreationTime(strFileName) & vbCrLf
strInfo &= "Last modified : " & File.GetLastWriteTime(strFileName) & vbCrLf
strInfo &= "Last accessed : " & File.GetLastAccessTime(strFileName) & vbCrLf
Return strInfo
End Function
Private Sub txtInput_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtInput.KeyDown
If e.KeyCode = Keys.Enter Then
Dim strFileName As String
strFileName = txtInput.Text
If File.Exists(strFileName) Then
txtOutput.Text = GetInformation(strFileName)
Try
Dim stream As StreamReader
stream = New StreamReader(strFileName)
txtOutput.Text = stream.ReadToEnd()
Catch ex As IOException
MessageBox.Show("File Error", "File Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
ElseIf Directory.Exists(strFileName) Then
Dim straDirectory As String()
txtOutput.Text = GetInformation(strFileName)
straDirectory = Directory.GetDirectories(strFileName)
txtOutput.Text &= vbCrLf & vbCrLf & _
"Directory content : " & vbCrLf
For i As Integer = 0 To straDirectory.Length - 1
txtOutput.Text &= straDirectory(i) & vbCrLf
Next
Else
MessageBox.Show(txtInput.Text & " does not exist ", "File Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End If
End Sub
Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
' ??? 为什么不要支持中文啊
' 当test.txt中含有中文字符时
txtInput.Text = "c:\test.txt"
End Sub
麻烦看一下如下代码
Private Function GetInformation(ByVal strFileName As String) As String
Dim strInfo As String
strInfo = strFileName & " exsits" & vbCrLf & vbCrLf
strInfo &= "Created : " & File.GetCreationTime(strFileName) & vbCrLf
strInfo &= "Last modified : " & File.GetLastWriteTime(strFileName) & vbCrLf
strInfo &= "Last accessed : " & File.GetLastAccessTime(strFileName) & vbCrLf
Return strInfo
End Function
Private Sub txtInput_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtInput.KeyDown
If e.KeyCode = Keys.Enter Then
Dim strFileName As String
strFileName = txtInput.Text
If File.Exists(strFileName) Then
txtOutput.Text = GetInformation(strFileName)
Try
Dim stream As StreamReader
stream = New StreamReader(strFileName)
txtOutput.Text = stream.ReadToEnd()
Catch ex As IOException
MessageBox.Show("File Error", "File Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
ElseIf Directory.Exists(strFileName) Then
Dim straDirectory As String()
txtOutput.Text = GetInformation(strFileName)
straDirectory = Directory.GetDirectories(strFileName)
txtOutput.Text &= vbCrLf & vbCrLf & _
"Directory content : " & vbCrLf
For i As Integer = 0 To straDirectory.Length - 1
txtOutput.Text &= straDirectory(i) & vbCrLf
Next
Else
MessageBox.Show(txtInput.Text & " does not exist ", "File Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End If
End Sub
Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
' ??? 为什么不要支持中文啊
' 当test.txt中含有中文字符时
txtInput.Text = "c:\test.txt"
End Sub