如果目标目录中存在文件,则从当前目录中删除文件的最佳方法

时间:2015-09-20 22:46:02

标签: excel-vba vba excel

如果文件存在于目标目录中,我需要删除该文件,如果它不存在,则将文件从Mydir移动到Desdir。

如果目标存在于destDir中并且不将其移至destDir,请建议从MyDir中删除该文件的最佳方法?谢谢。

请参阅以下代码:

On Error Resume Next
        If Dir(destDir & "\" & strFileName2) = "" Then'//file doesn't exist in destDir
            FileSys.MoveFile Source:=myDir & "\" & strFileName2,   Destination:=destDir & "\" '//move the file
        Else
        '//delete this file from myDir and do not move the file
        'code?
        End If
        On Error GoTo 0

0 个答案:

没有答案