I ran into a similar problem. What do you think about starting with:
FileInfo _fileinfo = null;
After that, you can simply do:
_fileinfo = new FileInfo(<string of file with path>);
Then you will have an object that you could pass as a parameter to your methods. Do not try to check if your object is null before trying to get values ββfor .Name, etc.
if(null != _fileinfo) {
source share