vbscript 中的过程调用或参数无效 [英] Invalid procedure call or argument in vbscript
问题描述
我正在使用 vb 脚本将文件上传到服务器.我遇到的问题是,当我将文件设置为这样的 ASCII 格式时......
I am using vb script to upload a file to the server. The problem I'm having is that when I set the file to ASCII format like this...
Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)
当调用 sub 时出现错误,提示
I get an error when the sub is called that says
无效的过程调用或参数
但如果我将文件设置为 unicode
but if I set the file to unicode
Set oFile = oFS.CreateTextFile(sPath & FileName, True, True)
上传成功,但由于编码错误而无法打开.如果格式为 ASCII,则产生错误的行是这一行
it uploads successfully but will not open because of the incorrect encoding. The line that produces the error is this one if format is ASCII is this one
oFile.Write BinaryToString(FileData)
其中 oFile
是我在上面创建的 ASCII 文件
where oFile
is the ASCII file I had created above
这里是产生错误的源代码.是我下网的上传功能..
Here is the source code that produces the error. It's an upload function I got off the net..
Public Sub SaveToDisk(sPath)
Dim oFS, oFile
Dim nIndex
If sPath = "" Or FileName = "" Then Exit Sub
If Mid(sPath, Len(sPath)) <> "" Then sPath = sPath & ""
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
If Not oFS.FolderExists(sPath) Then Exit Sub
Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)
oFile.Write BinaryToString(FileData)
oFile.Close
End Sub
Function BinaryToString(Binary)
'Antonin Foller, http://www.motobit.com
'Optimized version of a simple BinaryToString algorithm.
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
BinaryToString = pl1 & pl2 & pl3
End Function
可能是服务器上的配置吗?如果这有任何意义,请帮助..
Could it be configurations on the server? If this makes any sense please help..
推荐答案
我怀疑 BinaryToString 不仅返回 ASCII(实际上是当前的 OEM 代码页)字符,还返回 OEM 代码页集之外的 unicode 范围内的其他字符.
I suspect BinaryToString returns not only ASCII (actually the current OEM codepage) characters but also other characters in the unicode range that are outside the OEM codepage set.
BinaryToString 到底是做什么的?
What exactly does BinaryToString do?
这篇关于vbscript 中的过程调用或参数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!