filecopy in VB6


When I try to copy files in VBA I get the following Error;

Compile error: expected Function or variable. Am I missing library reference?

Seems like in can not file the function FileCopy in a library.

bin2003Asked:
Who is Participating?
 
ms_sanjayConnect With a Mentor Commented:
Hi Bin2003,
   Try this

FileCopy StrSource,StrDest.

Hope it helps.

Thanks
Sanjay Samuel.
0
 
bin2003Author Commented:

Programming is in Access 2003
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Show us your code.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
programmer1024Commented:
Probably have to reference the FileSystemObject.
0
 
bin2003Author Commented:

Code is : VB 6

    VarReturn=FileCopy(strsource,strDest)
0
 
markerringtonCommented:
Use FileSystemObject

Dim oFSO as new FileSystemObject

oFSO.Copy ([File to copy],[Destination])
0
 
rixlabsCommented:
0
 
Zak-RCommented:

are you trying to copy a file to another location?
for example: file.exe from "C:\" to "C:\WINDOWS" ?

0
 
dhavalislovelyCommented:
hi,

Try to use as following,

FileCopy "c:\d.htm", "d:\d.htm"

Here d.htm is the file that you want to copy from c: to d:

Best Regards,
Dhaval.

0
 
sagaragrawalCommented:
FileCopy will do the needful.

Actually its a Sub, which cannot return anything. So, you should not try to accept the return val of FileCopy Subroutine, means you should not write anything on the left hand side of the FileCopy procedure call.

Enjoy !!!
0
 
Zak-RCommented:

This code will do the job even better:

Dim mByte() As Byte
Open "C:\FileName.exe" For Binary As #1
Open "C:\WINDOWS\Any-Name.exe" For Binary As #2
ReDim mByte(0 To LOF(1))
Get #1, , mByte()
Put #2, , mByte()
Close #1
Close #2

If you want to change the name of the original app for out put you can do that too.
point to the folder where the file is, then select the destination folder for the copy.

Good luck
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.