我有以下代码..我在此语句中收到无效的调用或过程txsOutput.Writeline txsInput1.ReadAll ..组合文件是一个文本文件,其中包含一些此格式的条目
名称test.css.
有人可以告诉我脚本有什么问题.
Dim strInputPath1
Dim txsInput1,txsOutput
Dim FSO
Dim Filename
Set FSO = CreateObject("Scripting.FileSystemObject")
strOutputPath = "C:\txt3.txt"
Set txsOutput = FSO.CreateTextFile(strOutputPath)
Set re = New RegExp
re.Pattern = "\s+"
re.Global = True
Set f = FSO.OpenTextFile("C:\combination.txt")
Do Until f.AtEndOfStream
tokens = Split(Trim(re.Replace(f.ReadLine, " ")))
extension = Split(tokens(0),".")
strInputPath1 = "C:\inetpub\wwwroot\data\p\" & tokens(1) & "\" & extension(1) & "\" & tokens(0)
Loop
f.Close
WScript.Echo strInputPath1
Set txsInput1 = FSO.OpenTextFile(strInputPath1, 1)
txsOutput.Writeline txsInput1.ReadAll
txsInput1.Close
txsOutput.Close
Run Code Online (Sandbox Code Playgroud)
调用TextStream.WriteLine时的错误5通常是由于尝试写入TextStream无法编码的数据引起的:
尝试将"U + 1F00ἀe1 bc 80 GREEK SMALL LETTER ALPHA with PSILI"写入用/'ASCII'编码打开的流:
>> Set f = goFS.CreateTextFile(".\tmp.txt")
>> f.WriteLine "AÄ"
>> --- no news here means: written ---
>> f.WriteLine ChrW(&H1F00)
>>
Error Number: 5
Error Description: Invalid procedure call or argument
Run Code Online (Sandbox Code Playgroud)
为了证明这一点:
>> f.close
>> Set f = goFS.CreateTextFile(".\tmp.txt", True, True) ' overwrite, unicode
>> f.WriteLine ChrW(&H1F00)
>>
>> --- no news are good news --
Run Code Online (Sandbox Code Playgroud)
由于数据源(.ReadAll())似乎来自WWW,因此它很可能包含非ASCII/ANSI文本.但是请注意,如果输入是由ASCII文本流上的.ReadAll()输入的UTF-8,那么打开Unicode(= UTF-16)的输出文件将无济于事.