把开发过程中较好的一些内容段做个备份,下面的内容段是关于C#从DirectoryInfo获得目录属性的内容。
using System;
using System.IO;
class MainClass {
static void Main(string[] args) {
FileInfo file = new FileInfo("c:\a.txt");
DirectoryInfo dir = file.Directory;
Console.WriteLine("Checking directory: " + dir.Name);
Console.WriteLine("In directory: " + dir.Name);
Console.Write("Directory exists: ");
Console.WriteLine(dir.Exists.ToString());
if (dir.Exists) {
Console.Write("Directory attribute list: ");
Console.WriteLine(dir.Attributes.ToString());
}
Console.WriteLine();
}
}
网友评论