Reg-输入超过文件结尾时出错-VbScript

Reg-输入超过文件结尾时出错-VbScript,vbscript,Vbscript,我编写了一个简单的程序,使用FileSystemObject从文本文件中写入和读取数据,但它不起作用,并给我一个运行时错误: 输入超过文件末尾 请让我知道我在这里犯的错误 'Here is the Program - Dim Fso 'Reference obect to File system Dim TxtObj 'Reference to Text stream object Dim Txt 'Reference to Text stream object to open

我编写了一个简单的程序,使用
FileSystemObject
从文本文件中写入和读取数据,但它不起作用,并给我一个运行时错误:

输入超过文件末尾

请让我知道我在这里犯的错误

'Here is the Program - 

Dim Fso    'Reference obect to File system
Dim TxtObj 'Reference to Text stream object
Dim Txt    'Reference to Text stream object to open file
Dim i      'To Read Text in file

Set Fso = CreateObject("Scripting.FileSystemObject")

Set Txtobj = Fso.CreateTextFile("C:\Users\ACER\Desktop\Project Folder\NewText_3.txt")

Txtobj.Write("Hello")

Txtobj.Close

Set Txt = Fso.OpenTextFile("C:\Users\ACER\Desktop\Project Folder\NewText_3.txt",1)

Do while Txt.AtEndOfStream<>1
  i = Txt.Read(1)
Loop

Msgbox i

Txt.close
”这是程序-
Dim Fso对文件系统的参考对象
Dim TxtObj'对文本流对象的引用
Dim Txt对要打开文件的文本流对象的引用
调暗i'以读取文件中的文本
设置Fso=CreateObject(“Scripting.FileSystemObject”)
设置Txtobj=Fso.CreateTextFile(“C:\Users\ACER\Desktop\Project Folder\NewText\u 3.txt”)
Txtobj.Write(“你好”)
Txtobj.关闭
Set Txt=Fso.OpenTextFile(“C:\Users\ACER\Desktop\Project Folder\NewText\u 3.Txt”,1)
在Txt.AtEndOfStream1时执行
i=Txt.Read(1)
环
Msgbox i
Txt.close
输出:

cscript 14481096.vbs
got H
got e
got l
got l
got o
got     <-- aka cr
got     <-- aka lf (in case you are wondering)

非常感谢,我在下面的程序中做了一些更改,例如,我将文本写入流的末尾,而不是读取,并且我得到了一个运行时错误-错误的文件模式。Dim Fso“Reference obect to File system Dim TxtObj”Reference to text stream object Dim Txt“Reference to text object File Set Fso=CreateObject”(“Scripting.FileSystemObject”)设置Txtobj=Fso.CreateTextFile(“C:\Users\ACER\Desktop\Project Folder\NewText\u 5.txt”)直到Txtobj.AtEndofStream Txtobj.Write(“Hello”)循环Txtobj为止。Close@user1925406幸运的是,如果您正在编写,则没有“直到文件结束”的概念。
cscript 14481096.vbs
got H
got e
got l
got l
got o
got     <-- aka cr
got     <-- aka lf (in case you are wondering)
>> WScript.Echo CInt(True), CInt(False)
>>
-1 0
>>