Listbox File Copy
Hi All,
i have managed to get all my code to work suffieintly except for the one major part..lol
my application at the moment lists files that exist in one folder on a local machine and then scans the folder on a network machine to see which files dont exist, it then yields all files in there exact source path which dont lie on the network machine. and it also tells me how many files are missing in total,
the only thing i dont know where to start with is how do i get the files to copy over to the other machine , connection is already established between the tow machines and have full control permissions...
i do believe however that the Filesystemobject is required but how do i also get my app to know that it has copied all the files out the listbox
please help
many thanks
[840 byte] By [
Spumbu1977] at [2007-11-11 7:45:53]

# 1 Re: Listbox File Copy
I think your problem could be as easy as;
Dim Index As Long
For Index = 0 To List1.ListCount - 1
FileCopy List1.List(Index), Destination
Next Index
You would need to ensure that the listbox contained the full path to the file and that the destination modified the path to point to the new computer.
Steve. :cool:
# 2 Re: Listbox File Copy
it is a datalist box since i could not get my adodc control to list its search string results in my listbox
# 3 Re: Listbox File Copy
below is the code i am using, with the debug.print command i see that the system recognises the file in question but the filcopy command is doing nothing the file never seems to cop across no matter how long i wait
please could someone look through the code below and see if anything is obviously worng or a i just being stupid
Dim Index As Long
DESTINATION = "" & Text15 & "" & Text9 & ""
Debug.Print DESTINATION
For Index = 0 To List1.ListCount - 1
FileCopy List1.List(Index), DESTINATION
Debug.Print List1.List(Index)
Next Index
thanks
# 4 Re: Listbox File Copy
Hi Spumbu1977,
Assuming that the list contents are an exact path for the file you want to copy i.e. "C:\TestProg\ThisFileToCopy.txt"
Then I think that your Destination maybe the problem.
DESTINATION = "" & Text15 & "" & Text9 & ""
I don't see the reason for the "", it is important that the Destination path be as complete and accurate as the List path.
You must remember that network protocols are slightly different. So the file above would be "\\NetworkComputerName\C\ThisFileToCopyText". No colon after the 'C'.
So FileCopy "C:\TestProg\ThisFileToCopy.txt","\\NetworkComputerName\C\ThisFileToCopyText".
Let us know if this helps.
Steve.
# 5 Re: Listbox File Copy
FileCopy requires the name of a file as the second argument.
Assuming the Destination is a folder, use:
FileCopy List1.List(Index), DESTINATION & "\" & List1.List(Index)
if the items added to the list are absolute path names like
C:\MyTempFile\file1.txt
then you have to split the string to get only the file name (file1.txt in this case). Use InStrRev to get the last postion of the "\", and Right$ to get the last part of the string (not tested):
Right$(list1.item(index), len(list1.item(index) - isstrrev(list1.item(index))
Marco
mstraf at 2007-11-11 17:30:28 >

# 6 Re: Listbox File Copy
Thanks Marco, but if you had looked closer you would have seen that
FileCopy "C:\TestProg\ThisFileToCopy.txt","\\NetworkComputerName\C\ThisFileToCopyText".
Was simply a typo which should have read
So FileCopy "C:\TestProg\ThisFileToCopy.txt","\\NetworkComputerName\C\ThisFileToCopy.txt".
I tested the above before posting and it worked a charm.
Now all we need is for the original poster to confirm it works for him.
Steve.
# 7 Re: Listbox File Copy
thanks Steve , worked like a charm for me too
many thanks