A
Anders Norås [MCAD]
That's true, but it doesn't mean that you don't need to use 'Try...Catch'
use try-catch as a lazy way to check if the files exists.
From the design guidelines for application developers (MSDN):
a.. All code paths that result in an exception should provide a method to
check for success without throwing an exception. For example, to avoid a
FileNotFoundException you can call File.Exists. This might not always be
possible, but the goal is that under normal execution no exceptions should
be thrown.
Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Yes, you need to catch exceptions when working with files, but you shouldn'twhen attempting to open a file.
use try-catch as a lazy way to check if the files exists.
From the design guidelines for application developers (MSDN):
a.. All code paths that result in an exception should provide a method to
check for success without throwing an exception. For example, to avoid a
FileNotFoundException you can call File.Exists. This might not always be
possible, but the goal is that under normal execution no exceptions should
be thrown.
Anders Norås
http://dotnetjunkies.com/weblog/anoras/