Jump to content
Sign in to follow this  
Nachiket

Change the content of existing text file

Recommended Posts

Nachiket

Say, I have a file named sample.txt with the following contents : -

This is my first program

Hello

Hi

I have written the following lines of code to open the file using autoit

$d = "D:\"

$f = "sample.txt"

run( "cmd /c " & """" & $d & $f & """", "", @SW_HIDE )

WinClose("sample.txt - Notepad")

Send("!n")

Now I want to replace line2 in the sample.txt with some other content say "Bye"

How can I do it ?

Share this post


Link to post
Share on other sites
zfisherdrums

Hello Nachiket,

Try this:

#include <File.au3>
$textFile = "sample.txt"
_FileWriteToLine( $textFile, 3, "Bye", True )

Zach...

Edited by zfisherdrums

Share this post


Link to post
Share on other sites
Nachiket

Hello Nachiket,

Try this:

#include <File.au3>
$textFile = "sample.txt"
_FileWriteToLine( $textFile, 3, "Bye", True )

Zach...

Thanks fisher , its working

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  

×