解析:
Option Explicit
Dim fso As New FileSystemObject
Dim newfolder As Folder
上面在通用中写入
下面建立一个按钮打入代码 '后面是解释
Private Sub Command1_Click()
Set newfolder = fso.GetFolder(InputBox("文件要建立在哪个盘?如c:")) '这边也可以用inputbox("要建立的文件夹!")
'创建文件夹
If (fso.FolderExists("c:\windows") = True) Then 'c盘windows是都有的所以用c:\windows
fso.CreateFolder (InputBox("文件的全url?如d:\esinc"))
MsgBox ("新建成功!")
Else
MsgBox ("新建不成功!")
End If
Set newfolder = Nothing
End Sub
引用FSO(Microsoft Scripting Runtime),然后写出Dim FSO As New FileSystemObject
FSO.DeleteFolder ThePath 'ThePath即文件夹路径,而且不必先清空文件夹
或:(不必引用FSO)
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.DeleteFolder ThePath 'ThePath即文件夹路径,而且不必先清空文件夹
试一试
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)