autoit基础 FileOpen 读写txt文件
OS : Windows 10 Version 21H1
AutoIt : v3.3.16.0
blog : 师万物
typesetting : Markdown
script
my.ini
hello world
123456789
#comments-start
FileOpen ( "filename" [, mode = 0] )
Opens a file for reading or writing.
FileClose ( "filehandle" )
Closes a previously opened file.
#comments-end
#include
Global $file
; 只读模式
$file = FileOpen(@DesktopDir & "\my.txt", $FO_READ)
#comments-start
FileRead ( "filehandle/filename" [, count] )
Read in a number of characters from a previously opened file.
FileReadLine ( "filehandle/filename" [, line = 1] )
Read in a line of text from a previously opened text file.
#comments-end
If $file = -1 Then
ConsoleWrite("error")
Else
ConsoleWrite(FileRead($file))
ConsoleWrite(@CRLF)
ConsoleWrite(FileReadLine($file, 2))
EndIf
FileClose($file)
#comments-start
FileWrite ( "filehandle/filename", "text/data" )
Write text/data to the end of a previously opened file.
FileWriteLine ( "filehandle/filename", "line" )
APPend a line of text to the end of a previously opened text file.
#comments-end
;追加写入模式
$file = FileOpen(@DesktopDir & "\my.txt", $FO_APPEND)
If $file = -1 Then
ConsoleWrite("error")
Else
FileWriteLine($file, 2)
FileWrite($file, "a")
EndIf
FileClose($file)
Go
>"D:\Develop\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "E:\autoit\demo.au3"
hello world
123456789
123456789>Exit code: 0
my.ini
hello world
1234567892
a
学习资源
autoit
autoit-docs
IT天空
msdn
51CTO社区
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~