[Solved] c# write to file try catches [closed]


To wrap up this discussion. From @Erresen, “you’re currently catching ALL exceptions with your current catch.”

This is fine if you don’t want / need to do something specific based on the specific exception received.

However, as @Johny Mopp mentioned, ObjectDisposedException and IOException are potential exceptions. Perhaps, if you have an IOException, you’ll want to create an alert and notify the user that the method could not access the file, it was blocked, or wait a moment of time to try the file again. But for ObjectDisposedException your only option may be to notify the user that the action is impossible. So you’ll want to catch the exceptions individually and handle them appropriately.

solved c# write to file try catches [closed]