0

有没有办法使用 FileSystemObject 将查询输出写入文本文件?

4

1 回答 1

1

查询结果的格式是什么?如果它是一个简单的字符串,你也许可以做这样的事情,或者你可能必须提取你需要的位。

下面是使用文件系统对象将字符串写入文本文件的代码:

Const fsoForAppend = 8

Dim objFSO
Dim queryResult

queryResult = 'OMG no results'

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

'Open the text file
Dim objTextStream
Set objTextStream = objFSO.OpenTextFile("C:\path\to\logfile.txt", fsoForAppend)

'Write the results to the textfile
objTextStream.WriteLine queryResult

'Close the file and clean up
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
于 2012-02-27T16:54:31.003 回答