我需要一个VB脚本,它将在C:\ Documents and Settings \ All Users \ Application Data \ secon \ smartapp中创建名为“listitem”的文本文件 至C:\ Documents and Settings \ All Users \ Application Data \我们可以将其设为'CommonAppDataFolder'
任何人都知道这个
答案 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)
以下是一些提示:
Shell.Namespace(35)
方法。 (35是根据ShellSpecialFolderConstants Enumeration的文件夹ID。)有关示例,请参阅this question。FileSystemObject.BuildPath
方法。FileSystemObject.CreateTextFile
方法。希望你能亲自管理好自己。 :)