Jump to content
Sign in to follow this  
legend

filewrite

Recommended Posts

legend

Hi. When you write something to a .txt file, it's by default writting it to the end of the file, how would you write it to the top of the file instead?

Share this post


Link to post
Share on other sites
kylomas

legend,

Are you talking about appending to the top of the file or overwritting the file?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
stormbreaker

Something like:

#include <Constants.au3>
 
;I will write a line first.
FileWrite("mkish.txt", "My name is MKISH")
$CONTENT = FileRead("mkish.txt")

; Now, I will add something before that line.
$hFile = FileOpen("mkish.txt", 1)
FileSetPos($hFile, 0, $FILE_BEGIN)
FileWrite($hFile, "I wrote." & $CONTENT)
FileClose($hFile)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites
legend

something sort of like that :) the thing is

the thing is, It writes to the same line, if there already exists a line.

1.

2. this line already existslMy name is MKISH

3.

while instead it should do it like this

1. My name is MKISH

2. this line already exists

3.

Edited by legend

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  

×