I'm processing all excel files in a particular folder
Dim dirInfo As New DirectoryInfo(spreadsheetFolder)
excelFiles = dirInfo.GetFiles("*.xlsx")
In this folder the "~$weird.xlsx" files sometimes appear, I'm not interested in these files and want to skip them.
I'd like to just skip any file that is hidden. The problem here is that fileinfo.attributes doesn't just contain the hidden attribute, it is
Hidden Or Archive Or NotContentIndexed {8226}
The code that I've found all over the net only works if hidden is the only attribute, what do I do if there are others too?
I know that I could just ignore anything that starts "~$" but that isn't fun and this problem is bugging me now!
Thanks guys
You can use the HasFlag property. Sample code:
Dim excelFiles() As FileInfo = dirInfo.GetFiles("*.xlsx")
For Each curFile In excelFiles
If (curFile.Attributes.HasFlag(FileAttributes.Hidden)) Then
'This one is hidden
End If
Next
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With