I have a Data DVD I created that has about 1500 files on it.
Somehow, some of the files are not readable.
I wrote a program in VB 6 using the FileSystemObject to copy the
files from the DVD to a hard drive. When the app hits a bad file, I
want it to skip that file and reset the drive by ejecting the disk
and loading it again.
I wrote an error handler that is supposed to do that, reset the drive
and resume the copy process. But for some reason, VB does not see
the error. I even tried On Error Resume Next and test for the error,
but every time the program hits a bad file, I get the default VB
error window popping up.
Does anyone have any idea why my error handler doesn't want to kick
in and handle the error?
Here is the code's main loop.
On Error GoTo SetDriveAgain
Me.Show
ResetDrive "E:"
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\music.mdb"
conn.Open
strTarget = "C:\Documents and
Settings\Administrator.HOMESERVER\Desktop\Music\"
On Error Resume Next
Set fso = New FileSystemObject
Set folder = fso.GetFolder("e:\")
i = 0
rs.Open "Songs", conn, adOpenKeyset, adLockOptimistic
rs.MoveFirst
Do While Not rs.EOF()
strName = rs("Title")
Me.lblSong.Caption = strName
DoEvents
DoEvents
If Not fso.FileExists(strTarget & strName) Then
DoEvents
fso.CopyFile "e:\" & strName, strTarget & strName ' Line
that causes the error
If Err = 0 Then
rs("Success") = True
Else
Err.Clear
rs("Success") = False
ResetDrive "E:"
End If
End If
rs.MoveNext
Loop
rs.Close
conn.Close
Set folder = Nothing
Set fso = Nothing
Set rs = Nothing
Set conn = Nothing
Exit Sub
SetDriveAgain:
' If the error is -2147024873 from the file system object being
' unable to copy the file, then the default error window pops up
' and program execution never gets in here
If Err.Number = -2147024873 Then
ResetDrive "E:"
Resume Next
Else
MsgBox "Unhandled Error"
End If
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To reply to this message, go to:
http://groups.yahoo.com/group/visualbasic6programming/post?act=reply&messageNum=17745
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/visualbasic6programming/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/