Skip to content

Instantly share code, notes, and snippets.

@longtth
Last active February 23, 2018 10:18
Show Gist options
  • Save longtth/f9250884bf8654a24cb5249582f525a5 to your computer and use it in GitHub Desktop.
Save longtth/f9250884bf8654a24cb5249582f525a5 to your computer and use it in GitHub Desktop.
C# Check path is a file or dir
public class FileDirChecker
{
public bool isDirectory(string path)
{
bool ret = false;
// get the file attributes for file or directory
FileAttributes attr = File.GetAttributes(path);
if (attr.HasFlag(FileAttributes.Directory))
ret = true;
else
ret = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment