Would you please clarify this statement:
but it doesn't work properly
What are the cases for "not properly"?
Regarding question:
Does your task require to know if its file or directory?
In case no (i.e. you just want to have "true" if file exists), you can use File.Exists and get needed result.
No exceptions thrown in case you're worried.
var filePath = @"d:\Storage\Repo\Detrack\Detrack.bak";
var dirPath = @"d:\Storage\Repo\Detrack\";
var dirPathWithoutTrailingSlash = @"d:\Storage\Repo\Detrack";
Console.WriteLine("Path ({0}) exists = {1}", filePath, new FileInfo(filePath).Exists);
Console.WriteLine("Path ({0}) exists = {1}", dirPath, new FileInfo(dirPath).Exists);
Console.WriteLine("Path ({0}) exists = {1}", dirPathWithoutTrailingSlash, new FileInfo(dirPathWithoutTrailingSlash).Exists);
Console.ReadLine();
Results are:
Path (d:\Storage\Repo\Detrack\Detrack.bak) exists = True
Path (d:\Storage\Repo\Detrack\) exists = False
Path (d:\Storage\Repo\Detrack) exists = False