Reputation: 91
I'm trying to do a recursive loop through "Start Menu" folder using following code:
Function(string pathFolder) {
Shell32.Shell shell = new Shell32.Shell();
Shell32.Folder folderObj = shell.NameSpace(pathFolder);
foreach ( Shell32.FolderItem2 item in objFolder.Items() ) {
string typeItem = folderObj.GetDetailsOf(item, 2);
if ( typeItem == "File folder" ) {
string folderName = folderObj.GetDetailsOf(item, 0);
Function(pathFolder + "\\" + folderName);
} else {
// do smomething...
}
}
The problem is Shell.Namespace works fine for some folders, not all. For those not-working folders, Shell.Namespace return null even these folders do exist.
What's wrong with my code?
Upvotes: 1
Views: 1308
Reputation: 288
Why are not you using System.IO namespace classes? I think it has more advanced API. For your case it maybe security issues.
Upvotes: 1