天天看點

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