使用Vb脚本创建文件

时间:2010-06-17 09:38:47

标签: vbscript

我需要一个VB脚本,它将在C:\ Documents and Settings \ All Users \ Application Data \ secon \ smartapp中创建名为“listitem”的文本文件 至C:\ Documents and Settings \ All Users \ Application Data \我们可以将其设为'CommonAppDataFolder'

任何人都知道这个

2 个答案:

答案 0 :(得分:1)

好的,让我们看看我是否记得如何做到这一点......

Dim fso 'As Scripting.FileSystemObject
Dim stream 'As Scripting.TextStream

Set fso = CreateObject("Scripting.FileSystemObject")

'Check that the secon folder exists
If fso.FolderExists("C:\Documents and Settings\All Users\Application Data\secon") Then
Else
    fso.CreateFolder("C:\Documents and Settings\All Users\Application Data\secon")
End If

'Check that the smartapp folder exists
If fso.FolderExists("C:\Documents and Settings\All Users\Application Data\secon\smartapp") Then
Else
    fso.CreateFolder("C:\Documents and Settings\All Users\Application Data\secon\smartapp")
End If

'Create the file as ASCII text, overwrite it if it already exists
Set stream = fso.CreateTextFile("C:\Documents and Settings\All Users\Application Data\secon\smartapp\listitem.txt", true, false)

'Close it neatly
stream.Close

'Clean up
Set stream = Nothing
Set fso = Nothing

答案 1 :(得分:1)

以下是一些提示:

希望你能亲自管理好自己。 :)