Mar 13

Today I”ve just lost 30 mins trying to enumerate the items that exist inside a folder with the Gadget API. Guess what? The docs aren”t correct (I”m not sure why, since Gadgets exist for a long time now). Several things I”ve found today:

  • I couldn”t manage to get the System.Shell.Folder.parse method to work;
  • There isn”t an Items property on a System.Shell.Folder object
  • The same thing goes for the methods of that class (at least, copyHere and moveHere – I tried these)

Solutions: for the parse method,  I”ve manage to use the System.Shell.itemFromPath to get a reference to a folder object (I”m still not sure on why the parse method didn”t work with me – I”m probably doing something wrong). If you need to get the items that exist inside a folder, you must use the SHFolder property (which the docs don”t mention) and only then you”ll get references to those elements. Here”s a quick example of how you can use this info (the sample shows how to copy items from one folder to another):

var currentFolder = System.Shell.itemFromPath( “some path here” );
var folder = System.Shell.itemFromPath( “some path here” );
for( var i = 0; i < folder.SHFolder.Items.count; i++ ){
   var item = folder.SHFolder.Items.item(i);
   currentFolder.SHFolder.copyHere( item, 16 + 256 + 512 );

btw, I”ve just opened a new thread on the gadget forums. If you know the answer, please add it to the comments or as reply to that thread.

2 comments so far

  1. arenda kvartir peterburg bystro
    2:29 am - 12-15-2007

    energosnabzhenie kvartiry blagoveschensk arenda kvartir 2 aya kvartira kupit kvartiru predlozheniya arenda kvartir peterburg bystro kuplyu 1komnatnuyu kvartiru oformit pokupka kvartir ekaterinburg sdat kvartiru marksistskaya rynok kvartir sankt peterburg

  2. nedvizhimost sdayu tomsk
    4:00 pm - 12-16-2007

    nedvizhimost sdayu tomsk nedvizhimost sdayu tomsk nedvizhimost sdayu tomsk nedvizhimost sdayu tomsk nedvizhimost sdayu tomsk nedvizhimost sdayu tomsk