1

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?

Joseph Do
  • 91
  • 4

1 Answers1

1

Why are not you using System.IO namespace classes? I think it has more advanced API. For your case it maybe security issues.

user1429899
  • 288
  • 5
  • 15
  • It's because I want to use GetDetailsOf() method of Shell object to retrieve some other file's information, for example: target path of shortcut links. – Joseph Do Mar 20 '13 at 16:21
  • Oh, never thought about them(. In any case you can try using System.IO classes to check if you get these not-working folders or find out whether they throw any exceptions. – user1429899 Mar 20 '13 at 16:32
  • You're right. Using System.IO.Directory is much easier for my case, I just haven't thought about that before. Thank you! Anyway, any suggestion for my question? – Joseph Do Mar 20 '13 at 16:33