|
Dim dlg As New OpenFileDialog
dlg.Multiselect = False
dlg.CheckFileExists = True
If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim fs As IO.FileStream = dlg.OpenFile()
Dim bzData As Byte()
ReDim bzData(fs.Length)
fs.Read(bzData, 0, fs.Length - 1)
Dim strFileData As String = System.Text.Encoding.ASCII.GetString(bzData)
Dim res As System.Text.RegularExpressions.MatchCollection
res = System.Text.RegularExpressions.Regex.Matches(strFileData, "\r\n")
Dim strRes As String = String.Format("一共有{0:d}行。", res.Count + 1)
MessageBox.Show(strRes)
End If
这个是用vb.net写的。诈一看好像没什么,眼明的人估计看出来了。vb.net里,用了c#的转义字符\r\n,这么说,vb.net以后不用再使用vbcrlf来表示回车换行了?直接用"\r\n"了?天哪,这个是微软独具匠心的设计?还是一个疏漏? |
|