English 中文(简体)
VB文本中的数字线
原标题:Counts line in a text file VB

我正在寻找一种办法,在文本档案中计算线数,但不包括作为最后线的CRLF。

任何机会都有一个简单的法典实例。

最佳回答

问(尽管我发现在谷歌找你的问题的题目):

IO.File.ReadAllLines("C:UsersDanDesktop	est.txt").Length

如果你最终对空线感到担忧,那么,在你找到一条带内容之前,就从所有线上走,并删除所有线,直到最后。 这是一件容易的事,因为:

IO.File.ReadAllLines("C:UsersDanDesktop	est.txt")

Returns a vector of Strings. Hope this helps.

问题回答

为此:

TextBox1.Text = ""

With OpenFileDialog1
.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
.Filter = "Text Files (*.txt)|*.txt"
If .ShowDialog <> DialogResult.OK Then Exit Sub
End With

Dim intLines As Integer = 0
Dim sr As New IO.StreamReader(OpenFileDialog1.FileName)
Do While sr.Peek() >= 0
TextBox1.Text += sr.ReadLine() & ControlChars.CrLf
intLines += 1
Loop
sr.Close()
MessageBox.Show(intLines, Me.Text)

基本上,你们需要校准5号总书,然后检查是否将超文本与特别安全局联系起来,并确保你改用java字母。





相关问题
Sorting a very large text file in Java

I have a large text file I need to sort in Java. The format is: word [tab] frequency [new line] The algorithm for sorting is: Read some of the file, filtering for purlely alphabetic words. Once you ...

lseek function problem in a copy file program!

Got to use lseek function in this program below... Program is simply copying file (that already exist). I wanned to copy the existing file with the chars from the end of file for example: Sorce_File....

How do i write a txt file using Microsoft Dynamics AX?

I want to write a txt file (just like i d do in visual studio with c# using string writer and everything, with which i m already very familiar) what class and method do i use? how does it work? ...

text file reading in c#

I have a text file, its the content from a mail body.it includes html codes. I want to take only href tags from that text file.I want to do this with asp.net c# web application. Does any one have a ...

libsvm model file format

According to this FAQ the model format in libsvm should be straightforward. And in fact it is, when I call just svm-train. As an example, the first SV for the a1a dataset is 1 3:1 11:1 14:1 19:1 39:...

StreamReader C#

While reading a text file(which contains the location of a file to be exported to a database) using the streamReader function in C#, how can I add a confirmation message to the code that will be ...

Reading a text file and exporting its contents to sql

I m trying to have files(.shp and image file types) that are listed(the location) in a text file exported to a database, by importing it into the manifold program and then exporting them from there ...

热门标签