SPFolder doesn't expose any direct property which can be used to analyze if the folder is hidden.
I got stuck into this and could get any solution from Internet also. So decided to write this blog post.
At some places, people are talking about analyzing SPFolder.Properties.Count which should be equal to 21 if the folder is visible. Unfortunately, that's not true !
While looking at SPFolder properties for a hidden folder, I came across 'Item' property (SPListItem type).
For hidden folders, this property was Null regardless of the content in that folder.
For visible folder, it was either 0 or greater than 0 but was not Null even if folder is empty.
So in my view, you should always use 'Item' property of SPFolder to analyze its visibility as follows:
If(SPFolderObj.Item == Null)
//This folder is hidden
Else
//This folder is Visible
I got stuck into this and could get any solution from Internet also. So decided to write this blog post.
At some places, people are talking about analyzing SPFolder.Properties.Count which should be equal to 21 if the folder is visible. Unfortunately, that's not true !
While looking at SPFolder properties for a hidden folder, I came across 'Item' property (SPListItem type).
For hidden folders, this property was Null regardless of the content in that folder.
For visible folder, it was either 0 or greater than 0 but was not Null even if folder is empty.
So in my view, you should always use 'Item' property of SPFolder to analyze its visibility as follows:
If(SPFolderObj.Item == Null)
//This folder is hidden
Else
//This folder is Visible