Looking a little closer at your code, it seems that the issue is exactly that you are inlining parameters - that is a more difficult to way to do it.
When I read it last night, I though file
was a file name, but I see now that it is the image itself. Thus, the parameters should be passed this way:
query.Parameters.Add("@file", SqlDbType.VarBinary, -1)Value = file;
Also, I have a very old code sample on my web site for how to read binary data: https://www.sommarskog.se/blobload.txt. I don't know how useful it is, but you can look at it.
(But when it comes to the pure .NET part, you should listen more to Karen, because she knows .NET a lot better than I do. I'm an SQL Server guy.