KingSencat
asked on
Moving Files To Onother Folder ( Visual Basic v6.0 )
I already use a code to move all the files from c:\test\ to c:\test\test , however if the files already exist on c:\test\test i get error that file names already exist, how do i overwrite that files? Here is the code i use. Thanks
Dim MyOldpath As String, MyNewpath As String, MyName As String
MyOldpath = "c:\test\"' ' Set the path
MyNewpath = "c:\test\test\" ' The new path
MyName = Dir(MyOldpath, vbNormal) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
Name MyOldpath & MyName As MyNewpath & MyName ' This moves the files from MyOldPath to MyNewPath
MyName = Dir ' Get next entry.
Loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Although personally I think the native file commands in VB6 are not particularly good or intuitive; I much prefer using the FileSystemObject. If you want to use that, add a reference (Project|References...) to the Microsoft Scripting Runtime and use it like this:
Open in new window