// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; namespace E { public static class MyFile { public static bool MyExists(string fnm) { if(!File.Exists(fnm)) return false; return Array.Exists(Directory.GetFiles(Path.GetDirectoryName(fnm)), s => s == Path.GetFullPath(fnm)); } } public class Program { public static void Main(string[] args) { Console.WriteLine(MyFile.MyExists(@"C:\b.bat")); Console.WriteLine(MyFile.MyExists(@"C:\B.bat")); Console.WriteLine(MyFile.MyExists(@"C:\notexist.bat")); } } }