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
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now