VB编写一个程序,实现文件的移动。

2024-12-28 18:38:18
推荐回答(1个)
回答1:

写了一个函数,调用这个函数就好了,比如:MoveFile "D:\1.jpg", "D:\2.jpg"
返回值为true时代表移动成功,返回false时移动失败

Function MoveFile(ByVal SrcFile As String, DestFile As String) As Boolean
If SrcFile = "" Or DestFile = "" Then Exit Function
If SrcFile = DestFile Then Exit Function
On Error GoTo ErrTag
FileCopy SrcFile, DestFile
Kill SrcFile
MoveFile = True
Exit Function
ErrTag:

End Function