![](/img/trans.png)
[英]SSIS - Script task: Replace TEXT in text file using VBscript with dynamic file path
[英]Using FileSystemObject to Export VBScript Code to Text File
我希望將以下代碼的MsgBox oXMLHttp.responseText
部分替換為將結果導出到文本文件的代碼。 我檢查了這篇文章 ,發現以下代碼:
設置objFSO = CreateObject(“ Scripting.FileSystemObject”)
' How to write file
outFile="c:\test\autorun.inf"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "test string" & vbCrLf
objFile.Close
但是,我不知道如何實際執行此操作。 outFile是要創建的文件的位置和名稱嗎? 我相信是。 但是objFile.Write "test string" & vbCrLf
的目的是什么? 我的主要問題是:告訴要基於以下代碼處理的FileSystemObject是什么意思?
Dim request, oXMLHttp, url
url = "http://ws.cdyne.com/phoneverify/phoneverify.asmx"
request = "<?xml version='1.0' encoding='utf-8'?>" & _
"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
"<soap:Body>" & _
"<CheckPhoneNumbers xmlns=""http://ws.cdyne.com/PhoneVerify/query"">" & _
"<PhoneNumbers>" & _
"<string >1</string>" & _
"<string >2</string>" & _
"<string >3</string>" & _
"<string >4</string>" & _
"<string >5</string>" & _
"<string >6</string>" & _
"<string >7</string>" & _
"<string >8</string>" & _
"<string >9</string>" & _
"<string >10</string>" & _
"</PhoneNumbers>" & _
"<LicenseKey>Key</LicenseKey>" & _
"</CheckPhoneNumbers>" & _
"</soap:Body>" & _
"</soap:Envelope>"
Set oXMLHttp = CreateObject("MSXML2.ServerXMLHTTP")
oXMLHttp.open "POST", url, False
oXMLHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oXMLHttp.send request
response = oXMLHttp.responseText
MsgBox oXMLHttp.responseText
創建一個FileSystemObject :
Set objFSO = CreateObject("Scripting.FileSystemObject")
使用它來創建表示要創建的文件的TextStream對象(請參見此處以獲取CreateTextFile
函數):
Set objFile = objFSO.CreateTextFile("c:\\yourfile.txt", True)
使用TextStream
對象( objFile
)將文本寫入新文件:
objFile.Write "some text"
在您的情況下,您似乎要編寫HTTP響應:
objFile.Write oXMLHttp.responseText
關閉文件:
objFile.Close
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.