MedicaL Posted January 23, 2005 Posted January 23, 2005 Hello,I need to find out how to replace one file with another in Visual Basic 6. Say I need to replace the file C:\Program Files\Folder\test.txt with the file C:\Program Files\documents\test.txt . How would I write that? Thank You for your help
jdoe Posted January 23, 2005 Posted January 23, 2005 Using the default VB6 library you can do it like that...Kill "C:\Program Files\Folder\test.txt"FileCopy "C:\Program Files\documents\test.txt", "C:\Program Files\Folder\test.txt"It's not the perfect code but it work (with an error handler).To prevent an error with Kill you can remove the read-only attribute with SetAttr before calling Kill.And it's not a good idea to have hard coded path like that (use variable instead).
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now