VB 复制文件

   更新日期:2024.06.02
有两种操作方法
1.VB自己的命令
filecopy text1.text,text2.text
2.VBS的命令
Set fso = CreateObject("Scripting.FileSystemObject")
fso.copy text1.text,text2.text
全部删除复制 移动的如下:
dim a,b,c
On Error Resume Next
c=inputbox("请输入操作代码:1.删除;2.复制,3.移动","6921833","D:")
a=inputbox("请输入源文件的目录","6921833","D:")
if c<>1 then
b=inputbox("请输目标文件夹","6921833","D:")
else
b=0
end if
Tree(a,b,c)

Set WshSHell = WScript.CreateObject("WScript.Shell")
msgbox"OK"

Function Tree(sPath,spath2,whatdo)
On Error Resume Next
Dim WshSHell,oFso
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFso.GetFolder(sPath)
Set oSubFolders = oFolder.Subfolders
Set oFiles = oFolder.Files
For Each oFile In oFiles '文件
if whatdo=1 then
oFile.delete
elseif whatdo=2 then
oFile.Copy (spath2)
elseif whatdo=3
oFile.Movw (spath2)
end if
Next
For Each oSubFolder In oSubFolders
TreeIt(oSubFolder.Path)'递归
Next
Set objFolder=oFso.Getfolder(a)
Set subFolders=objFolder.subFolders
For Each subFolder In subFolders
On Error Resume Next
if whatdo=1 then subfolder.Delete(True)
If Err Then
err.Clear
Else
End If
Next
Set oFolder = Nothing
Set oSubFolders = Nothing
Set oFso = Nothing
End Function

VB帮不上你

相关链接

欢迎反馈与建议,请联系电邮
2024 © 视觉网