How to read from a text file using VBScript?

后端 未结 2 1355
刺人心
刺人心 2020-12-01 19:37

I am looking to see a simple way to read from and write to a text file using VBScript.

I think this is an acceptable method for writing to a file.

 D         


        
2条回答
  •  渐次进展
    2020-12-01 20:18

    Dim obj : Set obj = CreateObject("Scripting.FileSystemObject")
    Dim outFile : Set outFile = obj.CreateTextFile("in.txt")
    Dim inFile: Set inFile = obj.OpenTextFile("out.txt")
    
    ' Read file
    Dim strRetVal : strRetVal = inFile.ReadAll
    inFile.Close
    
    ' Write file
    outFile.write (strRetVal)
    outFile.Close
    

提交回复
热议问题