Discussion:
讀取txt問題
(时间太久无法回复)
hg
2006-08-30 03:05:01 UTC
Permalink
請問一下,我寫asp.net讀取txt檔(程式如下),為何txt檔的第一行都讀不到,只能從第二行開始讀取,煩請解答
謝謝!!


Dim myFile As System.IO.File
Dim FileStream As System.IO.Stream
Dim MyStreamReader As System.IO.StreamReader
FileStream = myFile.OpenRead("E:\web\file\test.txt")
MyStreamReader = New System.IO.StreamReader(FileStream,
System.Text.Encoding.Default)
Dim RecLine As String = MyStreamReader.ReadLine
While Not (RecLine Is Nothing)
RecLine = MyStreamReader.ReadLine
response.Write( RecLine & "<br>" )
End While
璉璉
2006-08-30 03:14:08 UTC
Permalink
Dim RecLine As String = MyStreamReader.ReadLine ' ³oÃä€wžgŪ±Œ€@Šæ€F
While Not (RecLine Is Nothing)
RecLine = MyStreamReader.ReadLine ' ³oÃäŪªº¬O²Ä€GŠæ
response.Write( RecLine & "<br>" )
End While
©ó news:6A069C20-DB45-4AFF-B46E-57F2FA20E49A%40microsoft.com µoªí
ÁÂÁÂ!!
Dim myFile As System.IO.File
Dim FileStream As System.IO.Stream
Dim MyStreamReader As System.IO.StreamReader
FileStream = myFile.OpenRead("E:\web\file\test.txt")
MyStreamReader = New System.IO.StreamReader(FileStream,
System.Text.Encoding.Default)
Dim RecLine As String = MyStreamReader.ReadLine
While Not (RecLine Is Nothing)
RecLine = MyStreamReader.ReadLine
response.Write( RecLine & "<br>" )
End While
--
­·¬ê¬ì§ÞÅçÃÒŠ³­­€œ¥q ASP.NET Web News Reader 0.2.3 UTF-8 Beta
ºô¯žŠa¹Ï http://tlcheng.twbbs.org/wwwmap.htm
¬y°ìšŸ¬x/°Ï°ì€ôžê·œ/®}ª@ºô/ªŽºÀ¹Ï/»y­µ³q°T €å³¹»Pµ{Š¡
Basic/Fortran/Windows API/.Net/»²§U»¡©úÀÉ ­ì©lœX¡B€å³¹»P°Qœ×
·L³nµ{Š¡³]­p·s°Qœ×°Ï MSDN §Þ³Nœ×ŸÂ¡Aºô€ÍŠ^ÂЫá§Y®É²°T¡B¹q€l¶l¥ó³qªŸ¡G
http://forums.microsoft.com/msdn-cht/default.aspx?siteid=14
--
ASPNET News Reader http://tlcheng.twbbs.org/News/Reader.aspx
RSS 2.0 http://tlcheng.twbbs.org/News/rss2.aspx?Action=List&Newsgroup=microsoft.public.tw.dotnet.framework.aspnet
hg
2006-08-30 09:17:01 UTC
Permalink
謝謝你的幫忙!!

"璉璉" 來函:
Dim RecLine As String = MyStreamReader.ReadLine ' 這邊已經讀掉一行了
While Not (RecLine Is Nothing)
RecLine = MyStreamReader.ReadLine ' 這邊讀的是第二行
response.Write( RecLine & "<br>" )
End While
快速改你的程式可以把 Response.Write 這行移到上一行。
一般來說,若是文字檔不大,通常會直接把整個檔載入後,用 Replace 函數將換行字元替換為 <br />
於 news:6A069C20-DB45-4AFF-B46E-57F2FA20E49A%40microsoft.com 發表
請問一下,我寫asp.net讀取txt檔(程式如下),為何txt檔的第一行都讀不到,只能從第二行開始讀取,煩請解答
謝謝!!
Dim myFile As System.IO.File
Dim FileStream As System.IO.Stream
Dim MyStreamReader As System.IO.StreamReader
FileStream = myFile.OpenRead("E:\web\file\test.txt")
MyStreamReader = New System.IO.StreamReader(FileStream,
System.Text.Encoding.Default)
Dim RecLine As String = MyStreamReader.ReadLine
While Not (RecLine Is Nothing)
RecLine = MyStreamReader.ReadLine
response.Write( RecLine & "<br>" )
End While
--
風禹科技驗證有限公司 ASP.NET Web News Reader 0.2.3 UTF-8 Beta
網站地圖 http://tlcheng.twbbs.org/wwwmap.htm
流域防洪/區域水資源/徐昇網/玫瑰圖/語音通訊 文章與程式
Basic/Fortran/Windows API/.Net/輔助說明檔 原始碼、文章與討論
微軟程式設計新討論區 MSDN 技術論壇,網友回覆後即時簡訊、電子郵件通知:
http://forums.microsoft.com/msdn-cht/default.aspx?siteid=14
--
ASPNET News Reader http://tlcheng.twbbs.org/News/Reader.aspx
RSS 2.0 http://tlcheng.twbbs.org/News/rss2.aspx?Action=List&Newsgroup=microsoft.public.tw.dotnet.framework.aspnet
继续阅读narkive:
Loading...