本文整理汇总了C#中IFileInfo.GetAttributeString方法的典型用法代码示例。如果您正苦于以下问题:C# IFileInfo.GetAttributeString方法的具体用法?C# IFileInfo.GetAttributeString怎么用?C# IFileInfo.GetAttributeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileInfo
的用法示例。
在下文中一共展示了IFileInfo.GetAttributeString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLongProperty
private string GetLongProperty(IFileInfo info)
{
if (info == null)
return null;
var stringBuilder = new StringBuilder();
// permissions
string sAttributes = info.GetAttributeString();
stringBuilder.Append(sAttributes);
stringBuilder.Append(" 1 owner group");
// check whether info is directory
bool isDirectory = info.IsDirectory();
// size
string sFileSize = info.GetSize().ToString(); // if info is directory, the size will be 1
stringBuilder.Append(TextHelpers.RightAlignString(sFileSize, 13, ' '));
stringBuilder.Append(" ");
// modify time
DateTimeOffset fileDate = info.GetModifiedTime(); //if info is directory, the modify time will be the current time
// month
stringBuilder.Append(TextHelpers.Month(fileDate.Month));
stringBuilder.Append(" ");
// day
string sDay = fileDate.Day.ToString();
if (sDay.Length == 1)
stringBuilder.Append(" ");
stringBuilder.Append(sDay);
stringBuilder.Append(" ");
// year or hour:min
if (fileDate.Year < DateTime.Now.Year)
{
stringBuilder.Append(" " + fileDate.Year);
}
else
{
stringBuilder.Append(string.Format("{0:hh}:{1:mm}", fileDate, fileDate));
}
stringBuilder.Append(" ");
// filename
string path = info.Path();
if (isDirectory)
stringBuilder.Append(FileNameHelpers.GetDirectoryName(path));
else
stringBuilder.Append(FileNameHelpers.GetFileName(path));
// end
stringBuilder.Append("\r\n");
return stringBuilder.ToString();
}