Before calling the Close () method of the FileStream object, I disconnect the main USB drive. The Close () method throws an exception when it tries to discard unwritten data. If I suppress the exception (catch, but do not throw it over), the finalizer is called an arbitrary amount of time later. He will try to clear the unwritten data, but he will encounter the same error, because of which the application will stop working.
Is there a standard way to handle a failed Close () call? It seems that if Close () encounters an error, you either 1) skip the file descriptor, or 2) make the application stop working, none of which is acceptable.
source
share