Sub Process_Globals
Dim flist As List
Dim NotZero As Boolean
End Sub
Sub AppStart (Args() As String)
flist.Initialize
flist.AddAll(File.ListFiles("c:/temp"))
For Each filename As String In flist
checkforzeros("C:/temp/"&filename)
Next
End Sub
Sub checkforzeros(s As String)
If File.IsDirectory("",s) Then Return ' ignore directories
Dim in As InputStream
Dim flen As Int
in = File.OpenInput("",s)
Dim buf(in.BytesAvailable) As Byte
NotZero = False
flen = in.ReadBytes(buf,0,in.BytesAvailable) ' read the file
For a = 0 To flen-1 ' check each byte for 0x00 - exit on first non x00 as file is not just 0x00
If buf(a)<> 0x00 Then
NotZero = True
Exit
End If
Next
If Not(NotZero) Then Log(s&" is zero file and needs replacing")' is zero file you would copy backup to replace it after in.close
in.close ' close input stream
' if Not(NotZero) then DoYourBackupCopyHere()
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub