Software Development Network>> Visual C#>> How to set a .txt file to hide C# 2.0
It's as easy as setting the FileAttributes property of a FileInfo class that references the file ala:
FileInfo fi = new FileInfo(@"C:\Some Dir\Some Text File.txt");
//Add Hidden flag (using bitwise ORing to leave any other values in place)
fi.Attributes = fi.Attributes | FileAttributes.Hidden;
//Remove Hidden flag if it is checked
if ((fi.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
//using bitwise XORing to leave any other values in place and remove only the Hidden flag
fi.Attributes = fi.Attributes ^ FileAttributes.Hidden; }
How to set a .txt file to hide C# 2.0
spshah
Mike Haro
Zeldacat
It's as easy as setting the FileAttributes property of a FileInfo class that references the file ala:
FileInfo fi = new FileInfo(@"C:\Some Dir\Some Text File.txt");
//Add Hidden flag (using bitwise ORing to leave any other values in place)
fi.Attributes = fi.Attributes | FileAttributes.Hidden;
//Remove Hidden flag if it is checked
if ((fi.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
//using bitwise XORing to leave any other values in place and remove only the Hidden flag
fi.Attributes = fi.Attributes ^ FileAttributes.Hidden;
}