Board index » Visual Studio » Editing txt file.

Editing txt file.

Visual Studio369
Hi!



Here's what I need to do:



I have a text file of 141 lines which contains data considering

web-application. In line 5 of the txt-file, the username is introduced.

Now I would need a script, which would ask me the username, and then

the script would modify the Username section, in the line 5 of the

text-file.



So basicly I would need a "Username" -variable. The value of "Username"

would be entered by a user, and then the script should input the value

to the text file.



Do you have any ideas which would be an easy way to accomplish this? It

seems that FileSystemObject cannot modify text-files, is that right?



Thanks in advance,



Henri


-
 

Re:Editing txt file.

yes... the filesystem object.

you would read the contents of the file line by line, and at the same time

write it to a new file, changing the lines that you wish to change. when

youre done you would delete the old file





<henri.nevalainen@gmail.com>wrote in message

Quote
Hi!



Here's what I need to do:



I have a text file of 141 lines which contains data considering

web-application. In line 5 of the txt-file, the username is introduced.

Now I would need a script, which would ask me the username, and then

the script would modify the Username section, in the line 5 of the

text-file.



So basicly I would need a "Username" -variable. The value of "Username"

would be entered by a user, and then the script should input the value

to the text file.



Do you have any ideas which would be an easy way to accomplish this? It

seems that FileSystemObject cannot modify text-files, is that right?



Thanks in advance,



Henri







-

Re:Editing txt file.

bonjour henri,



Yes, fso can not "modify" a file, but it can read it and

re-write it.



In addition to the above, if the file is not too large,

you could read it in "all-at-once" with readall, then

change the user name with the replace function, then

re-write the (entire) file with the write method.



au revoir, jw



henri.nevalainen@gmail.com wrote:

Quote
Hi!



Here's what I need to do:



I have a text file of 141 lines which contains data considering

web-application. In line 5 of the txt-file, the username is introduced.

Now I would need a script, which would ask me the username, and then

the script would modify the Username section, in the line 5 of the

text-file.



So basicly I would need a "Username" -variable. The value of "Username"

would be entered by a user, and then the script should input the value

to the text file.



Do you have any ideas which would be an easy way to accomplish this? It

seems that FileSystemObject cannot modify text-files, is that right?



Thanks in advance,



Henri



-