Skip to content

Instantly share code, notes, and snippets.

@relliv
Created May 4, 2018 21:07
Show Gist options
  • Save relliv/74efeae26b8dc106a43dd2a5514c4eda to your computer and use it in GitHub Desktop.
Save relliv/74efeae26b8dc106a43dd2a5514c4eda to your computer and use it in GitHub Desktop.
C# Folder & File Exists Checks
if (File.Exists(@"C:\Users\usename\Documents\Folder\File.cs")) {
// File exists
}
else if (!File.Exists(@"C:\Users\usename\Documents\Folder\File.cs")) {
// File does not exists
}
if (Directory.Exists(@"C:\Users\usename\Documents\Folder")) {
// Folder exists
}
else if (!Directory.Exists(@"C:\Users\usename\Documents\Folder")) {
// Folder does not exists
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment