Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving files

Status
Not open for further replies.

DKL01

Programmer
Sep 14, 2000
233
US
Hi,

I was wondering what is the best way of MOVING files from one folder to another using Visual Basic. If error occurs it should call error routine. I really appreciate any suggestions.

Thanks
 
Hey DKL01,

Try to use the MoveFile method to move a file from one folder to another. To build an error handle.....do the following:

private sub MoveMyFile()
on error goto err_handle

obj.MoveFile Source, Destination

err_handle:
'Type your error handling statements here
end sub
 
Try using the Name function to change the absolute
address. For instance, if you want to move file1.txt from
C:\directory1 to C:\directory2, just add the line:

Name C:\directory1\file1.txt As C:\directory2\file1.txt

I haven't actually tried this, but it looks good.
 
THOMASING is right!!! Its the Name As method. Just don't forget to use "" for the filenames.

eg. Name "C:\FILENAME1" As "C:\FILENAME2"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top