Made more precise IsValidFile