2 ms·
As said in the previous comment, you can place a variable in an outside scope and assign to it from within an try-catch block to handle an open file stream in a
by neonsunset 2y ago
As said in the previous comment, you can place a variable in an outside scope and assign to it from within an try-catch block to handle an open file stream in a particular way upon failure. You can simply write more code to disambiguate and specifically handle errors from separate parts of the execution flow. In any case closing a file handle should never fail, but if it does - there are tools to deal with this.
- lostmsu 2y agoWell the point it: the problem is not as simple in C# as your initial snippet suggests.