Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

isFile() and isPicture() ??

Hey ;

I need a function to do a something like check if the path is a file and then to check if it's a picture ...

I currently make some thing like this :

On Error Goto NotPic
If dir(Text1) <> "" Then
Image1.Picture = LoadPicture(Text1)
Else
MsgBox "Not a file !"
End If
Exit Sub
NotPic:
MsgBox "Not a picture !"

I wish to have a better way to do this check without catching an error and as well without Image control at all somthing like isFile(Text1) and isImage(Text1) if it exist ...

Thank you for reply .
[597 byte] By [Amahdy] at [2007-11-11 9:56:10]
# 1 Re: isFile() and isPicture() ??
You could check the file extension to see if it's ".gif", ".jpg", etc., but the only way I know of to ensure that the file is indeed an image is to try to load it, as you are doing. You do not, however, have to use an Image control; you may simply assign LoadPicture to a variable of type StdPicture.
Phil Weber at 2007-11-11 17:23:28 >
# 2 Re: isFile() and isPicture() ??
This should work for determining if it is a path or not:
Function isPath(strPath As String) As Boolean
isPath = ((GetAttr(strPath) And vbDirectory) = vbDirectory)
End Function
Ron Weller at 2007-11-11 17:24:28 >
# 3 Re: isFile() and isPicture() ??
Thanks Phil; and Ron : but I'm trying to check the file not the directory ; I want to know the strpath contains a valid file or nop, and if true I want to check if it's a picture format ignoring extension whatever it is.
Amahdy at 2007-11-11 17:25:38 >
# 4 Re: isFile() and isPicture() ??
I don't know where I got this sample project, but it looks alot like what you are looking for. A way to see if the file is a valid Image file by checking its internal structure. It should be a good starting point.
Ron Weller at 2007-11-11 17:26:34 >
# 5 Re: isFile() and isPicture() ??
Perfect the member : GetImageFileInfo() make what I want exactly , it just needed to learn more about image prossesing [Not looking for video that's enough!!] .

Thanks Ron !
Amahdy at 2007-11-11 17:27:33 >