Run-time error '70'
Permission denied
Permission denied
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
Option Explicit
Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
Sub CopyFile(SourceFile As String, DestFile As String)
'---------------------------------------------------------------
' PURPOSE: Copy a file on disk from one location to another.
' ACCEPTS: The name of the source file and destination file.
' RETURNS: Nothing
'---------------------------------------------------------------
Dim Result As Long
If Dir(SourceFile) = "" Then
MsgBox Chr(34) & SourceFile & Chr(34) & _
" is not valid file name."
Else
Result = apiCopyFile(SourceFile, DestFile, False)
End If
End Sub
CopyFile "<path to Northwind.mdb>", "C:\Northwind.mdb"
Option Explicit
Sub CopyFile(SourceFile As String, DestFile As String)
'---------------------------------------------------------------
' PURPOSE: Copy a file on disk from one location to another.
' ACCEPTS: The name of the source file and destination file.
' RETURNS: Nothing
'---------------------------------------------------------------
Dim CopyString As String
If Dir(SourceFile) = "" Then
MsgBox Chr(34) & SourceFile & Chr(34) & _
" is not a valid file name."
Else
SourceFile = Chr(34) & SourceFile & Chr(34)
DestFile = Chr(34) & DestFile & Chr(34)
CopyString = "COMMAND.COM /C COPY " & SourceFile & _
" " & DestFile
Call Shell(CopyString, 0)
End If
End Sub
CopyFile "<path to Northwind.mdb>", "C:\Northwind.mdb"
Option Explicit
Sub CopyFile(SourceFile As String, DestFile As String)
FileCopy SourceFile, DestFile
End Function
CopyFile "<path to Northwind.mdb>", "C:\Northwind.mdb"
Keywords: KB207703, kbdta, kbprogramming, kbhowto, kberrmsg