Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

How to find a specific file by traversing hard disk using c#

$
0
0

Hi,

I am trying to find an .exe file which is residing in my local system. I was looking for a LINQ which can do the thing for me and i found this piece of code. But the issue is that it will throw exception when going through "Access Denied" directories. So can anyone please help me. 

 var ext = new List<string> {".exe"};
 var myFiles = Directory.GetFiles("C:\\", "*.*", SearchOption.AllDirectories).Where(s => ext.Any(file => s.EndsWith(file)));


Arjun Menon U.K


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>