|
-
Jun 1st, 2006, 02:26 AM
#1
Thread Starter
New Member
[RESOLVED] [2005] API File operations error with multiple folders to copy
Hi,
I'm using a Filecopy class with an API declaration and the following function: Private Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer
I want to copy some files and folders using this function (it gives me the OS dialog box of the progress of the copy, .net functions for folder copy don't exist I have noticed). Several folders can be selected and are inserted in a listbox (as a string in an arraylist)
Clicking an a button makes the selected locations being copied in an iteration: Dim intI As Integer
Dim blnFinished As Boolean = False
For intI = 0 To strSource.Count - 1
lnFinished = CopyFiles( strsource(intI), strdest)
Next
The first filecopy execution succeeds most of the time but going further through the loop gives me following error for other filecopies: cannot read from source file or disk. Sometimes the first file operation fails and others based on the source strings kept in the arraylist don't. I 'm not sure what exactly the problem is but I'm guessing that I need a way to wait until the first filecopy has terminated before another call is made to the function (or a way to check if fileoperation is possible). When I only select one folder for copy there's no problem. Maybe I may not use the iteration to copy muliple folders but don't know how to make the application copy muliple folders by 1 user interaction (buton click event)
I've looked in the basics of threading but am not sure if this is a solution for my problem. I'm a beginner and would appreciate a lot if somebody could give me a hint or example to solve this issue since I've spent a lot of time already looking into this but didn't find what I was looking for (maybe the fact that I don't know what I'm exaclty looking for has got something to do with it )
If you need more info don't hesitate...
Thanks
Pascal
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|