FileCopy overwriting files

robherms

Registered User.
Local time
Today, 10:46
Joined
Aug 18, 2006
Messages
15
I have a directory where I store the latest version of various PDF files. The files are moved to this directory via the FileCopy function. I am having a problem where if a file exists in the latest version directory (ie: c:\latest_files\file1.pdf) and a newer version is created (c:\file1\file1.pdf), the FileCopy function is not overwriting the file in the latest version directory. I know that I can always delete the file in the latest version directory and then copy the newer version over, but I would prefer if FileCopy would overwrite the file. Is there any way to do this?
Code:
strWEBPATH2 = PADIRECTORY + "PA" + strTitleNumber + ".pdf"

If funValidFileName("PA" + strTitleNumber + ".pdf") Then
            'Copy Files
            FileCopy SOURCEDIRECTORY + sNextFile, strWEBPATH2
End If 'End check for valid file names
 
You can use the Dir() function to see if the file exists and then use the Kill() function to delete it if it does, then copy the new over. I know it's not what you wanted to hear, but I believe that's pretty much what you're going to have to do if you want to use the FileCopy function and it isn't overwriting the existing file.
 

Users who are viewing this thread

Back
Top Bottom