.NET Framework 文件、目录和流操作全解析
1. 文件属性操作
在 .NET Framework 中, SetAttributes 和 GetAttributes 方法用于设置或返回一个以位编码的 FileAttributes 值。这个值是多种属性的组合,如 Normal (无属性)、 Archive 、 ReadOnly 、 Hidden 、 System 、 Directory 、 Compressed 、 Encrypted 、 Temporary 、 NotContentIndexed 等。
以下代码展示了如何显示 C 盘中的系统文件和隐藏文件:
' Affiche les fichiers système et cachés dans C:\.
For Each fname As String In Directory.GetFiles("C:\")
Dim attr As FileAttributes = File.GetAttributes(fname)
' Affiche le fichier s’il est marqué comme caché
' ou s’il s’agit d’un
超级会员免费看
订阅专栏 解锁全文
970

被折叠的 条评论
为什么被折叠?



