When I run PowerShell\'s Get-ChildItem on a directory (or any cmdlet that returns file system items), it shows a column called Mode
, like this:
IMHO, the most explanatory is the code itself:
if (instance == null)
{
return string.Empty;
}
FileSystemInfo baseObject = (FileSystemInfo) instance.BaseObject;
if (baseObject == null)
{
return string.Empty;
}
string str = "";
if ((baseObject.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
str = str + "d";
}
else
{
str = str + "-";
}
if ((baseObject.Attributes & FileAttributes.Archive) == FileAttributes.Archive)
{
str = str + "a";
}
else
{
str = str + "-";
}
if ((baseObject.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
str = str + "r";
}
else
{
str = str + "-";
}
if ((baseObject.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
str = str + "h";
}
else
{
str = str + "-";
}
if ((baseObject.Attributes & FileAttributes.System) == FileAttributes.System)
{
return (str + "s");
}
return (str + "-");