i have a variable named 'data' i need to write in to a textfile named "listfile.txt".Can you tell me the vbscript code to do that..And i need vbscript code for reading value from textfile "listfile.txt" also
+1
A:
Need help reading and writing text file using vbscript - Dev Shed
VBScript - FileSystemObject
http://ezinearticles.com/?VBScript---FileSystemObject&id=294348
ratty
2010-06-25 10:12:22
+1
A:
This question is fairly well covered in StackOverflow: http://stackoverflow.com/search?q=[vbscript]+read+text+file
Remou
2010-06-25 10:14:17
A:
To Write
Set objFileToWrite = CreateObject("Scipting.FileSystemObject").OpenTextFile("C:\listfile.txt",2,true)
objFileToWrite.WriteLine(data)
objFileToWrite.Close
Set objFileToWrite = Nothing
OpenTextFile parameters:
<filename>, IOMode (1=Read,2=write,8=Append), Create (true,false), Format (-2=System Default,-1=Unicode,0=ASCII)
To Read the entire file
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\listfile.txt",1)
strFileText = objFileToRead.ReadAll()
objFileToRead.Close
Set objFileToRead = Nothing
To Read line by line
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\listfile.txt",1)
Dim strLine
do while not objFileToRead.AtEndOfStream
strLine = objFileToRead.ReadLine()
'Do something with the line
loop
objFileToRead.Close
Set objFileToRead = Nothing
Tester101
2010-06-25 11:57:54