天天看点

VB拷贝文件

Q:用filecopy拷贝数据库文件,提示70错误,拒绝权限

A:出现70错误是因为你的档案被锁定,一般会出现在mdb,doc等文件

解决有很多办法,下面列出几种]

1、使用fso的copyfilem,先引用下Microsoft Scripting Runtime

Private Sub Command1_Click()

    Dim fso As FileSystemObject

    Set fso = CreateObject("Scripting.FileSystemObject")

    fso.copyfile source_file, target_file

End Sub

2、使用cmd下的copy命令,个人觉得不怎么好,因为系统不同,调用会出现问题。

3、API中间使用SHFileOperation

所以不要一味去着迷copyfile

原文地址:http://community.csdn.net/Expert/topic/4099/4099584.xml?temp=3.290957E-02