Jump to content

Change the content of existing text file


Nachiket
 Share

Recommended Posts

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 ?

Link to comment
Share on other sites

Hello Nachiket,

Try this:

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

Zach...

Edited by zfisherdrums
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...