Your input isnt a valid path, but a path with the addition ",-5566". In that case the
GetAttributes C function may return some value which doesnt work correct with the if/else code but
System.IO.File.GetAttributes is correctly throwing an exception.
Use the debugger to look at the details to find the problem.