Read and write into a file using VBScript

Posted by Maddy on Stack Overflow See other posts from Stack Overflow or by Maddy
Published on 2009-07-17T11:21:02Z Indexed on 2010/03/22 19:41 UTC
Read the original article Hit count: 463

Filed under:

How can we read and write some string into a text file using VBScript? I mean I have a text file which is already present so when I use this code below:-

Set fso = CreateObject("Scripting.FileSystemObject" )            
Set file = fso.OpenTextFile("C:\New\maddy.txt",1,1) 

This opens the file only for reading but I am unable to write anything and when I use this code:-

Set fso = CreateObject("Scripting.FileSystemObject" )            
Set file = fso.OpenTextFile("C:\New\maddy.txt",2,1)

I can just use this file for writing but unable to read anything. Is there anyway by which we can open the file for reading and writing by just calling the OpenTextFile method only once.

I am really new to VBScript. I am only familiar with C concepts. Is there any link to really get me started with VBScript?

I guess I need to have a good knowledge of the objects and properties concepts.

© Stack Overflow or respective owner

Related posts about vbscript