I find myself doing this a lot just to ensure the filename is not in use. Is there a better way?
Directory.Exists(name) || File.Exists(name)
You can use following function:
[DllImport("shlwapi", EntryPoint = "PathFileExists", CharSet = CharSet.Unicode)] public static extern bool PathExists(string path);