Ga naar inhoud

Kopieren van bestanden VB


Aanbevolen berichten

Hoop dat je hier wat aan hebt

FileCopy Statement

Copies a file.

Syntax

FileCopy source, destination

The FileCopy statement syntax has these named arguments:

Part Description ----------------------- source Required. String expression that specifies the name of the file to be copied. The source may include directory or folder, and drive.

destination Required. String expression that specifies the target file name. The destination may include directory or folder, and drive.

Remarks

If you try to use the FileCopy statement on a currently open file, an error occurs.

Link naar reactie
  • 3 weken later...
Option Explicit Public 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 Public Declare Function SHFileOperation Lib "shell32.dll" Alias _ "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long Const FO_MOVE = &H1 Const FO_COPY = &H2 Const FO_DELETE = &H3 Const FO_RENAME = &H4 Const FOF_MULTIDESTFILES = &H1 Const FOF_CONFIRMMOUSE = &H2 ' Not Implemented yet Const FOF_SILENT = &H4 ' don't create progress/report Const FOF_RENAMEONCOLLISION = &H8 ' rename files on collision Const FOF_NOCONFIRMATION = &H10 ' Don't prompt the user. Const FOF_WANTMAPPINGHANDLE = &H20 ' Fill in SHFILEOPSTRUCT.hNameMappings ' Must be freed using SHFreeNameMappings Const FOF_ALLOWUNDO = &H40 Const FOF_FILESONLY = &H80 ' on *.*, do only files - not directories Const FOF_SIMPLEPROGRESS = &H100 ' means don't show names of files Const FOF_NOCONFIRMMKDIR = &H200 ' don't confirm making any needed dirs Const PO_DELETE = &H13 ' printer is being deleted Const PO_RENAME = &H14 ' printer is being renamed Const PO_PORTCHANGE = &H20 ' port this printer connected to is being changed ' if this id is set, the strings received by ' the copyhook are a doubly-null terminated ' list of strings. The first is the printer ' name and the second is the printer port. Const PO_REN_PORT = &H34 ' PO_RENAME and PO_PORTCHANGE at same time. Public Sub ShellCopyFile(strSource As String, strDest As String) Dim lResult As Long Dim SHF As SHFILEOPSTRUCT With SHF .hwnd = hwnd .wFunc = FO_COPY .pFrom = strSource & vbNullChar & vbNullChar .pTo = strDest & vbNullChar & vbNullChar .fFlags = FOF_FILESONLY End With lResult = SHFileOperation(SHF) If lResult Then MsgBox "Error occurred!", vbInformation, "SHCOPY" End If End Sub
Link naar reactie

Om een reactie te plaatsen, moet je eerst inloggen

Gast
Reageer op dit topic

×   Geplakt als verrijkte tekst.   Herstel opmaak

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

  • Populaire leden

    Er is nog niemand die deze week reputatie heeft ontvangen.

  • Leden

    Geen leden om te tonen

×
×
  • Nieuwe aanmaken...