Hiding a File using C#
Feb 9, 2010
Hiding a File using C#
The FileInfo class is very useful class that contains methods for the creation, copying, deletion, moving, and opening of files. Here’s how to hide a file using C#.
class Program
{
static void Main(string[] args)
{
try
{
string filePath = @"D:\Network.txt";
FileInfo f = new FileInfo(filePath);
f.Attributes = FileAttributes.Hidden;
Console.WriteLine("File Hidden");
}
catch (Exception ex)
{
// handle ex
}
}
}
Share