Sign in to follow this  
Followers 0
maniootek

FileWrite to line number 1

3 posts in this topic

File 'test.txt' contains few lines of text, like here:

Line1
Line2
Line3

and when I run this code:

$file = FileOpen("test.txt", 1)

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, "Something")


FileClose($file)

my file would now looks like that:

Line1
Line2
Line3Something

Now, how to erase all lines in that text file and put this "Something" text to ONLY line 1

after run this code it should looks like that:

"Something"

(only 1 line)

Share this post


Link to post
Share on other sites



in FileOpen, use flag 2 to overwrite:

FileOpen("test.txt", 2)

whim

Share this post


Link to post
Share on other sites

Can't belive that I missed it.

Thanks !

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