I'm writing a program that list the contents of a CDrom and also the contents of the ZIP files.
When there is a bad Zip file on the CD, the program keeps traying to reed the file and after +- 50 times it gives the error and ends the function.
This function is called from an other function that scans al the files on the disc.
Is it possible to give an error but that the program continues with the next file ?
=============================
FUNCTION THAT SCANS THE FOLDER -
Private Function Write_Files(ByVal START_FOLDER)
-
Dim DE_FILE As Scripting.File
-
Dim SUBFOLDER As Scripting.Folder
-
Label_List_FolderBezig.Caption = START_FOLDER
-
Label_List_FolderBezig.Refresh
-
For Each DE_FILE In START_FOLDER.Files
-
On Error GoTo Volgende
-
Call Write_In_Textbox(DE_FILE.PATH)
-
Volgende:
-
Next
-
For Each SUBFOLDER In START_FOLDER.SubFolders
-
Call Write_Files(SUBFOLDER)
-
Next
-
End Function
-
========================================
FUNCTION WRITING THE CONTENTS OF THE FILE -
Private Function Write_In_Textbox(ByVal PATH_FILENAME As String)
-
Dim FileName As String
-
Dim LENGTE As String
-
'§ == for listing ZIP files ==
-
Dim ReadHead As typZipLocalFileHead
-
Dim FNum As Integer
-
Dim FileString As String
-
Dim SeekSize As Long
-
Const ZipLocalFileHeadSig As Long = &H4034B50
-
'§ ================
-
FileName = Right(PATH_FILENAME, Len(PATH_FILENAME) - InStrRev(PATH_FILENAME, "\"))
-
If Check_add_path Then
-
'§ Path en filename
-
If Check_AddDriveName Then
-
List_Lijst.AddItem PATH_FILENAME
-
Else
-
List_Lijst.AddItem Mid(PATH_FILENAME, InStr(PATH_FILENAME, "\") + 1)
-
End If
-
Else
-
'§ only filename
-
List_Lijst.AddItem FileName
-
End If
-
'§ is it a ZIP file: list the contents if asked
-
If (Right(FileName, 4) = ".zip" Or Right(FileName, 4) = ".ZIP") And _
-
Check_ExploreZIP Then
-
'§ Make sure file exists
-
On Error Resume Next
-
LENGTE = FileLen(PATH_FILENAME)
-
If LENGTE <> "" Then
-
'§ Get a free file handle and open the file
-
FNum = FreeFile()
-
On Error Resume Next
-
Open PATH_FILENAME For Binary Access Read Lock Write As #FNum
-
'§ Read a chunk signature
-
Do
-
On Error GoTo Error_in_File
-
Get #FNum, , ReadHead.zlfhSignature
-
'§ Check for a local file header signature
-
If (ReadHead.zlfhSignature = ZipLocalFileHeadSig) Then
-
'§ Ok, read the full structure
-
Seek #FNum, Seek(FNum) - 4
-
Get #FNum, , ReadHead
-
With ReadHead
-
'§ Get the file name
-
If (.zlfhFileNameLength) Then
-
FileString = Space(.zlfhFileNameLength)
-
Get #FNum, , FileString
-
If Mid(FileString, Len(FileString)) <> "/" And _
-
FileString <> "" Then
-
If Check_add_path Then
-
'§ Path en filename
-
If Check_AddDriveName Then
-
List_Lijst.AddItem _
-
PATH_FILENAME & " ==>[ " & FileString & " ]"
-
Else
-
List_Lijst.AddItem _
-
Mid(PATH_FILENAME, InStr(PATH_FILENAME, "\") + 1) & _
-
" ==>[ " & FileString & " ]"
-
End If
-
Else
-
'§ only filename
-
List_Lijst.AddItem _
-
FileName & " ==>[ " & FileString & " ]"
-
List_Lijst.Refresh
-
End If
-
End If
-
'§ No filename?
-
Else
-
List_Lijst.AddItem "Got file: [No name]"
-
End If
-
'§ Work out how much extra data to skip over
-
SeekSize = .zlfhCompressedSize
-
If (.zlfhExtraFieldLength) Then _
-
SeekSize = SeekSize + .zlfhExtraFieldLength
-
If (.zlfhBitFlag And &H4) Then _
-
SeekSize = SeekSize + 12
-
'§ Seek to next record
-
Seek #FNum, Seek(FNum) + SeekSize
-
End With
-
'§ Increment file count
-
Else
-
Exit Do
-
End If
-
Loop
-
Close #FNum
-
Else
-
MsgBox ("Error in ZIP filename: " & PATH_FILENAME)
-
End If
-
End If
-
Exit Function
-
Error_in_File:
-
MsgBox ("There is an error reading file: " & PATH_FILENAME)
-
List_Lijst.AddItem FileName & " ERROR READING FILE "
-
End Function