Sign in to follow this  
Followers 0
TuMiM

Filewrite to beginning and end of file

5 posts in this topic

Is there a way to use filewrite to write a line of text to the beginning and end of a text file?

Share this post


Link to post
Share on other sites



_FileReadToArray

_ArrayInsert

_ArrayAdd

_FileWriteFromArray

_FileWriteToLine()

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Hi,

;filewriteBegEnd.au3
$filename=@ScriptDir&"\test.txt"
FileDelete($filename)
FileWrite($filename, "OldLine1"& @CRLF&"OldLine2")
$s_FileInit = FileRead($filename)
FileDelete($filename)

$h_file = FileOpen("test.txt", 2);then fileopen in append  mode
FileWrite($h_file, "LinebAtStart"& @CRLF) ;write first line 
FileWrite($h_file, $s_FileInit & @CRLF); append the rest of the initial file
FileWrite($h_file, "LineEnd"); append last line
FileClose($h_file)
MsgBox(0,"","File ="& @CRLF& FileRead($filename))

Else, if it is a huge file, use tailRW , link from my sig.

Best, Randall

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0