i have got a command button on a form which used to copy the contents of the folder to another folder, however it is now throwing an error for some reason.
it comes up with the msg "error" because of the messagebox
can you guys tell me how to figure out why is it throwing an error?
VB Code:
Dim strt As New FileSystemObject
' 'this actually over writes all files in the currentDirPath directory with those stored under the initialize directory
Yes, but in the case there's a file that has the same name (has no extension) then it can't create a folder there. For all other cases, the overwrite parameter would have taken care of it.
If you decided to do the copy again... so the folder and files are already existing from the previous copy. And during the 2nd copy, a file in the folder was opened by another app.
leinad31 did not quite understand what you meant by
es, but in the case there's a file that has the same name (has no extension) then it can't create a folder there. For all other cases, the overwrite parameter would have taken care of it.
you mean if there is a file with the name as the containing folder?
brucevde, you mean if i am looking at the file in windows explorer i will get the error?
is there any way (error code) which will tell me why the error occured?
rhino, basically i have an initialise folder which contains inital settings in files, say i have fooinitialisefolder1 which has foo1.xls, foo2.xls, foo3.xls
and then i have a bunch of folders which the users can modify
e.g. i have a destination folder foodetfolder with the files foo1.xls, foo2.xls, foo3.xls (however foo1.xls, foo2.xls & foo3.xls have slightly different contents then the files in fooinitialisefolder)
now i have this initialise button which causes the overwriting or replacement of the foo1.xls, foo2.xls and foo3.xls files in the foodestfolder with the foo1.xls, foo2.xls & foo3.xls in the fooinitialisefolder
I'll tackle it from another direction... if you can have folders with extensions then you can have files with no extension. For a given name, either its a directory or a file it cant be both.
In the attached pic I renamed a folder to have an extension txt. So if yuo were doing a folder copy but there was already a file using the same name as the folder then an error will occur. That could be one source of error, brucevd pointed out another possible cause of the error.
If SampleProject-2 already exists in destination and is a file then an error will occur
If SampleProject-2 already exists in destination and is a folder then it will overwrite the folder and it's content
If while overwriting the content of SampleProject-2 it encounters a file that is being USED by another application (such as an open word document) then it can't overwrite that file and an error will occur
Having a folder open in windows explorer will not cause the error. It's having an open FILE that will cause an error.
thanks for the reply, then in that case i probably have an open file in the detination folder.
my source and destination folders both contain excel files, is there any way of checking if the destination foder contains an open file(any of the excel files is open?)?
none of myfies are open in MS excel, the copyfolder seems to be a temperamental function, sometimes it works,sometimes it does not. i have also checked in the task manager there is no instance of MS Excel running
Last edited by vb_student; Oct 6th, 2005 at 08:26 AM.