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
You can use Attributes
property of FileInfo class..
var fInfo = new FileInfo(..);
if (fInfo.Attributes.HasFlag(FileAttributes.Hidden))
{
}
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;
This is what you need:
bool isHidden = (File.GetAttributes(fileName) & FileAttributes.Hidden) == FileAttributes.Hidden;