Thuộc tính Line của ASP
Định nghĩa và cách sử dụng
Thuộc tính Line trả về số dòng hiện tại trong tệp TextStream (bắt đầu từ 1).
cú pháp:
TextStreamObject.Line
thực hành
<% dim fs,f,t set fs=Server.CreateObject("Scripting.FileSystemObject") set f=fs.CreateTextFile("c:\test.txt",true) f.WriteLine("Hello World!") f.WriteLine("How are you today?") f.WriteLine("Goodbye!") f.close Set t=fs.OpenTextFile("c:\test.txt",1) do while t.AtEndOfStream=false Response.Write("Line " & t.Line & ": ") Response.Write(t.ReadLine) Response.Write("<br>") vòng lặp t.Close %>
Kết quả đầu ra:
Dòng 1: Hello World! Dòng 2: Bạn có thế nào hôm nay? Dòng 3: Goodbye!