我有一个问题,我需要从文本文件中读取指定数量的字符,但指定的数量会有所不同,所以我不能使用常量EG:
variable = WhateverIsSpecified
strText = objFile.Read (variable) ' 1 ~ n+1
objOutfile.write strText
不是
strText = objFile.Read (n) ' n = any constant (interger)
使用第一种方式时,输出为空白(输出文件中没有字符)
提前致谢
更新
这些是代码较长的主要代码段
Set file1 = fso.OpenTextFile(file)
Do Until file1.AtEndOfStream
line = file1.ReadLine
If (Instr(line,"/_N_") =1) then
line0 = replace(line, "/", "%")
filename = file1.Readline
filename = Left(filename, len(filename)-3) & "arc"
Set objOutFile = fso.CreateTextFile(destfolder & "\" & filename)
For i = 1 to 5
line = file1.Readline
next
nBytes = line 'this line contains the quantity needed to be read eg 1234
Do until Instr(line,"\") > 0
line = file1.ReadLine
Loop
StrData = ObjFile.Read (nBytes)
objOutFile.Write StrData
objOutFile.close
End if
Loop
WScript.quit
答案 0 :(得分:0)
我自己的愚蠢错误,
StrData = ObjFile.Read (nBytes)
应该是
StrData = file1.Read (nBytes)