Assigning a
new
object to a variable almost always means that the variable is non-null, which makes the
if
evaluation meaningless. If creating an object like this might fail, the proper way is to use a static method along the lines of
var fileinfo = FileInfo.CreateNew(file);