Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bug in copyhere method!

Status
Not open for further replies.

dssjon

MIS
May 29, 2007
37
0
0
US
Hello all,

I'm using copyhere method to copy files and I want to overwrite existing files:

Code:
objFolder_DESTINATION.copyhere objFiles_SOURCE, 16

The only problem is that there is a bug in the overwrite functionality in the copyhere method. Does anyone know another simple way to overwrite files that I am copying, or a simple way to check those files and delete them before hand? It is not as simple as hard coding the file paths so I'm not sure exactly what to do. Here is my whole function:

Code:
Function UnzipFile(varFileName_SOURCE_COMPLETE As Variant, varFolderName_DESTINATION_COMPLETE As Variant) As String

On Error GoTo Function_Execution_Failure
    
Dim objFSO As New FileSystemObject
Dim objShellApplication As Variant
Dim objFiles_SOURCE As Variant
Dim objFolder_DESTINATION As Variant

    If objFSO.FileExists(varFileName_SOURCE_COMPLETE) = False Then
        UnzipFile = "Error: file " & CStr(varFileName_SOURCE_COMPLETE) & " does not exist, aborting operation."
        GoTo Function_Execution_Failure
    End If
    
    If objFSO.FolderExists(CStr(varFolderName_DESTINATION_COMPLETE)) = False Then
        objFSO.CreateFolder (CStr(varFolderName_DESTINATION_COMPLETE))
    End If

    Set objShellApplication = CreateObject("Shell.Application")
    
    Set objFiles_SOURCE = objShellApplication.Namespace(varFileName_SOURCE_COMPLETE).Items()
    
    Set objFolder_DESTINATION = objShellApplication.Namespace(varFolderName_DESTINATION_COMPLETE)
    
    objFolder_DESTINATION.copyhere objFiles_SOURCE, 16
 
    Wait
     
Function_Execution_Success:
    
    GoTo Quit_function
    
Function_Execution_Failure:

    UnzipFile = "Error: " & Err.Description
    Call reportError("UnzipFile", Err.Number, Err.Description)
    
Quit_function:

    Set objFSO = Nothing
    Set objShellApplication = Nothing
    Set objFiles_SOURCE = Nothing
    Set objFolder_DESTINATION = Nothing
    
End Function
 
I can't overwrite a file even if I tell it to, the confirm file replace dialog always pops up and I have to click "yes to all" even though the int flag 16 is set to always say yes to all.
 

a simple way to check those files and delete them before hand
How about.... [blue]Kill[/blue] [purple]FileName[/purple]


Randy
 
I'm afraid a .ZIP file is only an ersatz of a true FolderItem ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top