c# check if path is a file code example
Example 1: c# check if string is path or file
FileAttributes attr = File.GetAttributes(@"c:\Temp");
if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
MessageBox.Show("Its a directory");
else
MessageBox.Show("Its a file");
Example 2: how to check if a path is a directory or file c#
FileAttributes attr = File.GetAttributes(@"c:\Temp");
if (attr.HasFlag(FileAttributes.Directory))
MessageBox.Show("Its a directory");
else
MessageBox.Show("Its a file");