copying a file

How can i copy a file that is already open...

eg i want to make a copy of the file that is running.
It is possible doing it in windows...how can i do it in vb

do i use the copyfile api?
or what?
wormboy__6Asked:
Who is Participating?
 
mcriderConnect With a Mentor Commented:
Yes, you can use the copyfile API...

Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long

CopyFile "c:\windows\desktop\xxxtest.txt","c:\windows\desktop\xxxtest1.txt",0


Cheers!


0
 
mcriderCommented:
CopyFile Parameters


lpExistingFileName - Pointer to a null-terminated string that specifies the name of an existing file.
lpNewFileName - Pointer to a null-terminated string that specifies the name of the new file.
bFailIfExists - Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.

Cheers!
0
 
wormboy__6Author Commented:
cheers
0
 
mcriderCommented:
Thanks for the points! Glad I could help!

Cheers!
0
All Courses

From novice to tech pro — start learning today.