Как работать с файлами при помощи API
Private Declare Function CopyFile Lib "kernel32" Alias _ "CopyFileA" (ByVal lpExistingFileName As String, ByVal _ lpNewFileName As String, ByVal bFailIfExists As Long) As Long Private Declare Function MoveFile Lib "kernel32" Alias _ "MoveFileA" (ByVal lpExistingFileName As String, ByVal _ lpNewFileName As String) As Long Sub CopyMove() Dim strSource As String Dim strTarget As String Dim lngRetVal As Long strSource = "C:\yfile.txt" strTarget = "C:\indows\yfile.txt" '// Копируем файл lngRetVal = CopyFile(Trim$(strSource), Trim(strTarget), False) If lngRetVal Then MsgBox "Файл скопирован!" Else MsgBox "Ошибка!" End If '// Переместить файл lngRetVal = MoveFile(Trim$(strSource), Trim(strTarget)) If lngRetVal Then MsgBox "Файл перемещен!" Else MsgBox "Ошибка!" End If End Sub Источник: www.vbstreets.ru
|