I am checking images for width and height and trying to delete all that are not satisfying the if requirement. The If requirement works (from 12 -> 1) and i can not use f.delete in this case as it throws out an error "f is in use by another program; can not open image10.jpg" (12 and 11 do not satisfy the If requirement, 10 does).
How do i delete images that satisfy the If requirement?
Dim s As New DirectoryInfo("C:\Users\*\source\repos\CinemaSpider\CinemaSpider\bin\Debug")
Dim files As FileInfo() = s.GetFiles("*.jpg")
For Each f As FileInfo In files
Dim bmp As New Bitmap(f.FullName)
If bmp.Width.ToString() < 182 Or bmp.Height.ToString() < 268 Then
f.Delete()
End If