How to test if directory is hidden in C#?

前端 未结 4 1974

I have this loop:

  foreach (DirectoryInfo dir in downloadedMessageInfo.GetDirectories())
        {
            if (dir.Attributes != FileAttributes.Hidden)
         


        
4条回答
  •  一向
    一向 (楼主)
    2020-12-15 05:03

    This code works for me in VB.Net;

    If (dir.Attributes.Tostring.Contains("Hidden") Then
        ' File is hidden
    Else
        ' File is not hidden
    EndIf
    

提交回复
热议问题