Created
January 30, 2026 03:51
-
-
Save karenpayneoregon/3196e780b227212b95bd21fd4d5558ff to your computer and use it in GitHub Desktop.
Determines if path is a file or folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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