• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 129
  • Last Modified:

Easy vb-script question

How do I do if I want to open a file and write to it without writing over the old things in a file, e.g. how do I concatenate the new things with the old file with vb-script.
0
mdoland
Asked:
mdoland
1 Solution
 
halapayaCommented:
you can use Filesystem object of scripting run time.

Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")

Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)

MyFile.WriteLine("This is a test.")

MyFile.Close

u can open the file with different options; like delete all and create new, or open the file with existing stuff and write to it etc..etc

check the help on FileSystemObject.
0
 
VbmasterCommented:
I don't know if it works in vb-script cause I have never used vb-script but here's how to do it in vb..

Dim Filenr as Integer

Filenr = FreeFile
Open filename For Append As #Filenr
Print #Filenr, "This is a test."
Close #Filenr
0
 
mistawallCommented:
you have to open the file as append so it would be like


Set MyFile = fso.CreateTextFile("c:\testfile.txt", 8)

not true
0
 
mdolandAuthor Commented:
You are wrong halapaya. I know already all the things you wrote, and to redirect me to look for the answear myself is an easy way out. I have looked through all the info I found about it at MS website.
I will give the points to mistawall
0
 
mistawallCommented:
okay...
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now