Skip to content

Instantly share code, notes, and snippets.

@karenpayneoregon
Created January 30, 2026 03:51
Show Gist options
  • Select an option

  • Save karenpayneoregon/3196e780b227212b95bd21fd4d5558ff to your computer and use it in GitHub Desktop.

Select an option

Save karenpayneoregon/3196e780b227212b95bd21fd4d5558ff to your computer and use it in GitHub Desktop.
Determines if path is a file or folder
public class FileHelpers
{
public static (bool isFolder, bool success) IsFileOrFolder(string path)
{
try
{
var attr = File.GetAttributes(path);
return attr.HasFlag(FileAttributes.Directory) ? (true, true)! : (false, true)!;
}
catch (FileNotFoundException)
{
return (false, false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment