C#程序以获取有关文件的信息
获取有关文件的信息意味着获取为该特定文件设置的所有属性。例如,文件可以是普通文件,隐藏文件,存档文件等。
首先,使用FileInfo类-
FileInfo info = new FileInfo("hello.txt");现在,使用FileAttributes获取有关文件的信息-
FileAttributes attr = info.Attributes;
以下是代码-
示例
using System.IO;
using System;
public class Program {
public static void Main() {
using (StreamWriter sw = new StreamWriter("hello.txt")) {
sw.WriteLine("这是演示文字!");
}
FileInfo info = new FileInfo("hello.txt");
FileAttributes attr = info.Attributes;
Console.WriteLine(attr);
}
}输出结果
Normal
热门推荐
10 横幅元旦祝福语大全简短
11 别人结婚舞台祝福语简短
12 生日寿宴祝福语简短精辟
13 岁岁祝福语简短独特
14 中考祝福语简短高级句
15 公司文案生日祝福语简短
16 出院祝福语简短8字
17 给老板祝福语简短精辟
18 上海返乡祝福语简短精辟