|
-
Mar 22nd, 2006, 07:28 AM
#1
Thread Starter
Frenzied Member
Problem when checking for valid filetype
Hello, I'm using the code below to check how many valid avi videos there are in a folder.
Every time a valid avi video has been found, 1 should be counted up (ct). This works fine if there are only valid avi videos in the folder, but if I rename a mp3 audio file to .avi and put that file in the folder with the valid avi videos, then ct always returns "0".
Does anybody know what is wrong?
VB Code:
Public Function GetFileType(xFile As String) As String
On Error Resume Next
Dim ID As String * 300
Open xFile For Binary Access Read As #1
Get #1, 1, ID
Close #1
GetFileType = Mid(ID, 9, 8)
End Function
Private Sub cmdCheck_Click()
Dim ct As Integer
Dim a As String
Dim Valid_type As String
ct = 0
a = sPath & Dir(sPath & "*.avi")
Valid_type = GetFileType(a)
Do While LenB(a) > LenB(sPath)
If Valid_type = "AVI LIST" Then
ct = ct + 1
End If
a = sPath & Dir
Loop
Msgbox ct
End Sub
-
Mar 22nd, 2006, 07:31 AM
#2
Re: Problem when checking for valid filetype
You are checking the File type only once, so it will return only one. Try this instead:
VB Code:
Private Sub cmdCheck_Click()
Dim ct As Integer
Dim a As String
Dim Valid_type As String
ct = 0
a = sPath & Dir(sPath & "*.avi")
Do While LenB(a) > LenB(sPath)
[b]Valid_type = GetFileType(a) [/b]
If Valid_type = "AVI LIST" Then
ct = ct + 1
End If
a = sPath & Dir
Loop
Msgbox ct
End Sub
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Mar 22nd, 2006, 07:51 AM
#3
Thread Starter
Frenzied Member
Re: Problem when checking for valid filetype
Yes, that works fine. Thank you for your help
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
|