c# check if string is valid directory name code example Example: c# check if string is directory File.GetAttributes(data.Path).HasFlag(FileAttributes.Directory)