Generally if you are performing a single operation on a file, use the File
class. If you are performing multiple operations on the same file, use FileInfo
.
The reason to do it this way is because of the security checking done when accessing a file. When you create an instance of FileInfo
, the check is only performed once. However, each time you use a static File
method the check is performed.