复制 FileFolder
使用方法:
.CopyFile(Source, Dest [,Overwrite (True/False)]
.CopyFolder(Source, Dest [,Overwrite (True/False)]
以下代码说明了使用 CopyFile 方法将文件复制到新位置。使用 CopyFolder 方法可以为文件夹实现相同的功能。
码:
Dim objFso, strSourcePath, strDestPath
strSourcePath = "C:\Users\GS\Desktop\Source.txt"
strDestPath = "C:\Users\GS\Desktop\Dest.txt"
Set objFso = CreateObject("Scripting.FileSystemObject")
If objFso.FileExists(strSourcePath) then
objFso.CopyFile strSourcePath, strDestPath, True 'True indicates the overwritting of the file at the destination path i.e, if the file already exists, it will be overwritten
End If
Set objFso = Nothing