views:

93

answers:

3

How can I create or mark a file as hidden using .NET?

+10  A: 

Use File.SetAttributes. "Hidden" is just one of many available attributes.

Jacob
ThanX bro..!! one of other site gave me wrong information that- dotnet can-not hide a file.
pvaju896
+5  A: 

I assume you are referring to setting the file attribute to hidden in the file system. Please take a look at this link

airmanx86
+7  A: 

You set the hidden attribute of the file.

There are several ways of doing so - with File.SetAttributes or FileInfo.Attributes, you simply set the FileAttributes enumeration flag to hidden:

string path = @"c:\myfile.txt";
File.SetAttributes(path, FileAttributes.Hidden);
Oded