读取文本文件 [英] read text file
本文介绍了读取文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要阅读一个文本文件,但我需要从文件的第2行开始,如何
我可以从第二行开始阅读文本文件,而不是
文件中的第一行?
I need to read a text file but I need to start on line 2 of the file, How
can I start reading the text file starting with the second line and not the
first line in the file?
推荐答案
您好
seudo代码:
StreamReader st = new StreamReader(...)
string line = st.ReadLine();
while( (line = st.ReadLine())!= null)
{
}
st.Close();
欢呼,
-
Ignacio Machin,
ignacio.machin at dot.state.fl.us
佛罗里达州交通局
" microsoft.news.com" < CSharpCoder>在留言中写道
新闻:eL ************** @ TK2MSFTNGP14.phx.gbl ...
Hi
seudo code:
StreamReader st = new StreamReader( ... )
string line = st.ReadLine();
while( (line=st.ReadLine()) != null )
{
}
st.Close();
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"microsoft.news.com" <CSharpCoder> wrote in message
news:eL**************@TK2MSFTNGP14.phx.gbl...
我需要读一个文本文件,但我需要从文件的第2行开始,如何
我可以从第二行开始阅读文本文件,而不是文件中的第一行?
I need to read a text file but I need to start on line 2 of the file, How
can I start reading the text file starting with the second line and not the
first line in the file?
但是第一行不是NULL,它只是没有数据我正在寻找
for 。
第2行从我正在寻找的数据开始,所以我需要从第2行开始阅读
行。
Ignacio Machin(.NET / C#MVP)" < ignacio.machin AT dot.state.fl.us>在消息新闻中写道:
:O5 ************** @ tk2msftngp13.phx.gbl ...
but the first line isn''t NULL, it just doesn''t have the data i''m looking
for.
Line 2 starts with the data i''m looking for so I need to start reading the
lines from line 2 on.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:O5**************@tk2msftngp13.phx.gbl...
嗨
seudo代码:
StreamReader st = new StreamReader(...)
string line = st.ReadLine();
while((line = st.ReadLine) ())!= null)
{
}
st.Close();
欢呼,
-
Ignacio Machin,
ignacio.machin at dot.state.fl.us
佛罗里达州交通局
microsoft.news.com < CSharpCoder>在消息中写道
新闻:eL ************** @ TK2MSFTNGP14.phx.gbl ...
Hi
seudo code:
StreamReader st = new StreamReader( ... )
string line = st.ReadLine();
while( (line=st.ReadLine()) != null )
{
}
st.Close();
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"microsoft.news.com" <CSharpCoder> wrote in message
news:eL**************@TK2MSFTNGP14.phx.gbl...
我需要阅读一个文本文件,但我需要从文件的第2行开始,如何才能开始从第二行开始读取文本文件而不是文件中的第一行?
I need to read a text file but I need to start on line 2 of the file, How
can I start reading the text file starting with the second line and not
the first line in the file?
你只是丢弃第1行:)
这就是你不读的原因它在cicle中,就是你在哪里工作
工作
欢呼,
-
Ignacio Machin,
ignacio.machin at dot.state.fl.us
Florida Department of Transportation
" microsoft.news.com" < CSharpCoder>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
You are just discarding line 1 :)
that''s why you are not reading it in the cicle, that is where you do your
work
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"microsoft.news.com" <CSharpCoder> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
但是第一行不是空的,它只是没有我想要的数据
。第2行从我正在寻找的数据开始,所以我需要开始阅读第2行的
行。
Ignacio Machin(.NET / C#MVP)" < ignacio.machin AT dot.state.fl.us>
在消息新闻中写道:O5 ************** @ tk2msftngp13.phx.gbl ...
but the first line isn''t NULL, it just doesn''t have the data i''m looking
for.
Line 2 starts with the data i''m looking for so I need to start reading the
lines from line 2 on.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:O5**************@tk2msftngp13.phx.gbl...
嗨
seudo代码:
StreamReader st = new StreamReader(...)
string line = st.ReadLine();
while((line = st.ReadLine())!= null)
{
}
st.Close();
欢呼,>
-
Ignacio Machin,
ignacio.machin at dot.state.fl.us
佛罗里达州交通局
microsoft.news .COM" < CSharpCoder>在消息中写道
新闻:eL ************** @ TK2MSFTNGP14.phx.gbl ...
Hi
seudo code:
StreamReader st = new StreamReader( ... )
string line = st.ReadLine();
while( (line=st.ReadLine()) != null )
{
}
st.Close();
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"microsoft.news.com" <CSharpCoder> wrote in message
news:eL**************@TK2MSFTNGP14.phx.gbl...
我需要阅读一个文本文件,但我需要从文件的第2行开始,如何才能开始从第二行开始读取文本文件而不是文件中的第一行?
I need to read a text file but I need to start on line 2 of the file, How
can I start reading the text file starting with the second line and not
the first line in the file?
这篇关于读取文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文