Reputation: 244
File.SetAttributes((new FileInfo((new Uri(Assembly.GetExecutingAssembly().CodeBase)).LocalPath)).Name, FileAttributes.Hidden);
if(Check file Hidden )
....
else
()
I can not understand how to know that whether the file is hidden on the way
Upvotes: 9
Views: 7851
Reputation: 22866
For a single file operation prefer the System.IO.File
static methods ( and for multiple operations on the same file System.IO.FileInfo
) :
bool isHidden1 = File.GetAttributes(path).HasFlag(FileAttributes.Hidden);
//bool isHidden2 = (File.GetAttributes(path) & FileAttributes.Hidden) > 0;
//bool isHidden3 = ((int)File.GetAttributes(path) & 2) > 0;
Upvotes: 11
Reputation: 190907
This is what you need:
bool isHidden = (File.GetAttributes(fileName) & FileAttributes.Hidden) == FileAttributes.Hidden;
Upvotes: 6
Reputation: 116108
You can use Attributes
property of FileInfo class..
var fInfo = new FileInfo(..);
if (fInfo.Attributes.HasFlag(FileAttributes.Hidden))
{
}
Upvotes: 11