我使用VB腳本上傳文件到服務器。我遇到的問題是,當我設置文件,這樣的ASCII格式...無效的過程調用或參數在VBScript
Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)
我得到一個錯誤,當子叫,說
無效的過程調用或參數
,但如果我設置文件爲Unicode
Set oFile = oFS.CreateTextFile(sPath & FileName, True, True)
它上傳成功但由於編碼不正確而無法打開。 產生錯誤的線是這一個,如果格式是ASCII是這個
oFile.Write BinaryToString(FileData)
其中oFile
是我上述
創建的ASCII文件在這裏是產生錯誤的源代碼。這是一個上傳功能,我下車淨..
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
難道是在服務器上配置?如果這使得任何意義,請幫助..
中的FileData舉行哪些數據類型以及它是如何在第一時間獲得? – AnthonyWJones 2009-07-01 14:46:12