home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 27 / CDROM27.iso / share / progra / mai / Files, copying and moving with the API < prev    next >
Encoding:
Text File  |  1997-07-13  |  827 b   |  29 lines

  1. 'Description: Moves or Copies a file using API
  2.  
  3. 'Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
  4. 'Private Declare Function MoveFile Lib "kernel32" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
  5.  
  6.  
  7. 'Place the following code in under a command button or in a menu, etc...
  8.  
  9. source = "C:\myfile.txt"
  10. target = "C:\Windows\myfile.txt"
  11.  
  12.  
  13. 'Copy File
  14. A = CopyFile(Trim$(Source), Trim(Target), False)
  15. If A Then
  16.         MsgBox "File copied!"
  17. Else
  18.         MsgBox "Error. File not moved!"
  19. End If
  20.  
  21.  
  22.  
  23. 'Move File
  24. A = MoveFile(Trim$(Source), Trim(Target))
  25. If A Then
  26.         MsgBox "File moved!"
  27. Else
  28.         MsgBox "Error. File not moved!"
  29. End If