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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

overwrite file without prompt

Status
Not open for further replies.

elibb

Programmer
Oct 22, 2001
335
MX
hi, i have a vb6.0 applications, and i want to copy some files from one location to the other, some of those files already exist in the destination folder, and i want to overwrite them, how can i do that without prompting the overwrite window??

im copying the files like this:

i have this in a module:
Code:
Option Explicit
Private Type SHFILEOPSTRUCT
    hWnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAnyOperationsAborted As Boolean
    hNameMappings As Long
    lpszProgressTitle As String
End Type

Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40

Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
Dim sh_op As SHFILEOPSTRUCT

    With sh_op
        .hWnd = 0
        .wFunc = FO_COPY
        .pFrom = from_file & vbNullChar & vbNullChar
        .pTo = to_file & vbNullChar & vbNullChar
        .fFlags = FOF_ALLOWUNDO
    End With

    SHFileOperation sh_op
End Sub

and this is how i call the function:
Code:
    SHCopyFile new, old
old and new are the path where the file i want to copy is and the destincation path.

i can change the way im copying the file, i just dont know other way.. but the important thing here is the overwrite prompt.

thank you very much

Eli


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top