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
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短