1.FileReadLine
--------------------------------------------------------------------------------
从此前已打开的文本文件中读取指定行的字符.
FileReadLine ( 文件句柄 或 "文件名" [, 行号] )$file = FileOpen("D:\aaa.txt", 0)
If $file = -1 Then; 检查打开的文件是否可读
MsgBox(0, "错误", "不能打开文件.")
Exit
EndIf
While 1; 每次读取一行文本,直到文件结束.
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
MsgBox(0, "读取的行:", $line&@CRLF&@CRLF&@CRLF)
Wend
FileClose($file)
2.用UDF写入数组#include <file.au3>
Dim $aRecords
If Not _FileReadToArray("D:\aaa.txt",$aRecords) Then
MsgBox(4096,"Error", " error:" & @error)
Exit
EndIf
For $x = 1 to $aRecords[0]
Msgbox(0,'Record:' & $x, $aRecords[$x]&@CRLF&@CRLF&@CRLF)
Next
|