在VB中如何复制文件?
请问一下,在VB中如何复制文件?例如,我想把C:\1.mp3复制到D:\1.mp3?还有一个问题就是把同目录下的文件复制到其它地方。...
请问一下,在VB中如何复制文件? 例如,我想把C:\1.mp3复制到D:\1.mp3? 还有一个问题就是把同目录下的文件复制到其它地方。
展开
1个回答
展开全部
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询