以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]复制文件夹  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=84994)

--  作者:wusim
--  发布时间:2016/5/14 23:09:00
--  [求助]复制文件夹
复制文件夹文件 能不能目标位置和复制位置都可以手动选择,下面的代码怎样选
FileSys.CopyDirectory ("C:\\TestFiles""C:\\TestFiles2", True)
[此贴子已经被作者于2016/5/14 23:10:47编辑过]

--  作者:xiaoohoo
--  发布时间:2016/5/15 9:11:00
--  
        Dim dlg As New FolderBrowserDialog
        Dim Folder1, Folder2 As String

        dlg.Description = "选择文件夹1"
        dlg.ShowDialog()
        Folder1 = dlg.SelectedPath

        dlg.Description = "选择文件夹2"
        dlg.ShowDialog()
        Folder2 = dlg.SelectedPath

        FileSys.CopyDirectory(Folder1, Folder2, True)

--  作者:Hyphen
--  发布时间:2016/5/15 14:10:00
--  
http://www.foxtable.com/help/topics/0359.htm
--  作者:大红袍
--  发布时间:2016/5/15 22:12:00
--  

Dim dlg As New FolderBrowserDialog
Dim Folder1, Folder2 As String

dlg.Description = "选择文件夹1"
If dlg.ShowDialog = DialogResult.Ok  Then
    Folder1 = dlg.SelectedPath
    dlg.Description = "选择文件夹2"
    If dlg.ShowDialog = DialogResult.Ok  Then
        Folder2 = dlg.SelectedPath
        FileSys.CopyDirectory(Folder1, Folder2, True)
    End If
End If


--  作者:wusim
--  发布时间:2016/5/17 22:50:00
--  
Dim dlg As New FolderBrowserDialog
Dim Folder2 As String 
dlg.Description ="资料备份目录"
dlg.ShowDialog()
Folder2 = dlg.SelectedPath
FileSys.CopyDirectory(ProjectPath & "资料备份目录\\", Folder2, True)
我想把Project目录下的资料备份目录的整个文件夹复制到选定目录,但是上面的代码只能把Project目录下的资料备份目录\\的几个文件夹复制到选定目录,我想能够自动创建资料备份目录

--  作者:大红袍
--  发布时间:2016/5/17 23:28:00
--  
Dim dlg As New FolderBrowserDialog
Dim Folder2 As String
dlg.Description ="资料备份目录"
If dlg.ShowDialog = DialogResult.Ok  Then
    Folder2 = dlg.SelectedPath
    FileSys.CopyDirectory(ProjectPath & "资料备份目录\\", Folder2 & "\\资料备份目录", True)
End If

--  作者:wusim
--  发布时间:2016/5/18 8:40:00
--  
如果由ProjectPath & "资料备份目录\\", 复制到Folder2 & "\\资料备份目录", 想问一下当ProjectPath & "资料备份目录\\"下文件数量小于Folder2 & "\\资料备份目录"下的文件数,要把Folder2 & "\\资料备份目录"多出来的文件删除。如:ProjectPath & "资料备份目录下有1.doc、2.doc、3.doc 文件, ,而Folder2 & "\\资料备份目录"下有1.doc、2.doc、3.doc 、4.doc 文件,现在要复制后顺便删除文件4.doc
--  作者:Hyphen
--  发布时间:2016/5/18 9:01:00
--  
http://www.foxtable.com/help/topics/0341.htm

分别获取2个目录下的文件名称,循环比较判断是多余的进行删除

--  作者:大红袍
--  发布时间:2016/5/18 9:15:00
--  

回复9楼,你先选择的文件夹删除,然后再复制就行啊

 

http://www.foxtable.com/help/topics/0333.htm