How do I get the directory type (as displayed by Windows Explorer in the type column)  
Author Message
Glenn Skene





PostPosted: Visual C# General, How do I get the directory type (as displayed by Windows Explorer in the type column) Top

Hi. When enumerating through directories and subdirectories using Directory/DirectoryInfo, how do you get/set the directory type (as displayed by Windows Explorer in the Type column) Also, is there a way to get/set other fields supported by Windows Explorer such as Comments, Status, and Keywords



Visual C#4  
 
 
TaylorMichaelL





PostPosted: Visual C# General, How do I get the directory type (as displayed by Windows Explorer in the type column) Top

As far as I know there is no way to get this information directly through managed code. The unmanaged equivalent is SHGetFileInfo. The KB article http://support.microsoft.com/default.aspx/kb/319350 will tell you how to use the function in managed code.

As for getting comments and whatnot these are actually stored as data in a secondary stream. I think you'll end up using unmanaged code to get to them because NTFS streams are not exposed directly in .NET. Fortunately it is pretty straightforward as the standard file IO API works with streams as well. I believe the syntax is filename:streamname but I'm not 100% sure. Look up the help for File Streams in MSDN to get the actual syntax. Unfortunately I believe the .NET stream readers will fail with the syntax.

Michael Taylor - 11/29/06