เพื่อดึงแอตทริบิวต์ของไฟล์ ใช้ FileAttributes Enumeration มีสมาชิก compressed, directory, hidden ฯลฯ
ตรวจสอบว่าไฟล์ hidden ด้วยสมาชิก hidden
ถ้า FileAttributes.Hidden ถูกตั้งค่า แสดงว่าไฟล์ถูกซ่อน ขั้นแรก ดึง path เพื่อหาแอตทริบิวต์:
FileAttributes attributes = File.GetAttributes(path);
ถ้าตั้งค่าต่อไปนี้ แสดงว่าไฟล์ถูกซ่อนแล้ว:
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
Console.WriteLine("The {0} file is hidden.", path);