***************************************************************
asp net
一行一行的取讀取文字檔內的資料,並將所取的值回傳
    Private Function GetTextString() As String
        Dim value As String = ""
        'Dim a As String = ""
        Dim MySF As IO.StreamReader = New IO.StreamReader("c:1.txt", System.Text.Encoding.Default)
        'value = MySF.ReadToEnd()
        '讀取全部會包含換行符號
        Do While Not MySF.EndOfStream
            '讀取單行
            value = MySF.ReadLine
        Loop
        Return value
    End Function

***************************************************************
c#
一行一行的取讀取文字檔內的資料

StreamReader stmRdr = new StreamReader("TextFile1.txt");

string line = stmRdr.ReadLine();
while(line != null) {
  Console.WriteLine(line);
  line = stmRdr.ReadLine();
}


arrow
arrow
    全站熱搜

    Roger 發表在 痞客邦 留言(0) 人氣()