|
Dim dlg As New OpenFileDialog
dlg.InitialDirectory = "c:\"
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 ("There are {0: d} lines in total.", Res.Count + 1)
MessageBox.Show (strRes)
End If |
|