The example you wrote only gets the name of the file. It doesn't upload or do anything else.
IMO what you should do is to check if the file is open or not before uploading it. One way is the try to get a read/write lock on the file when you open it. See
File.Open Method (String, FileMode, FileAccess, FileShare)[
^]
If you cannot open the file exclusively, then show a message to inform the user to close the file.