VBS实用方法:CreateFileInFolder
@@@@@在指定文件夹下创建文本文件,如果文件夹/文件不存在则自动创建,已存在的覆盖@@@@@
Function CreateFileInFolder(FileName,Folder)
Dim RegEx, arrFolder, thisFolder,File
Set RegEx = New RegExp
RegEx.Pattern = "[^\\]+\\"
RegEx.IgnoreCase = True
RegEx.Global = True
Set arrFolder = RegEx.Execute(Folder)
Set RegEx = Nothing
Set fso = CreateObject("Scripting.FileSystemObject")
For Each SubFolder In arrFolder
thisFolder = thisFolder & SubFolder
If Not fso.FolderExists(thisFolder) Then
fso.CreateFolder(thisFolder)
End if
Next
Set fso = Nothing
File = Folder&FileName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(File)
Set objFSO = Nothing
End Function