private void doOpen()
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            AmjObject obj = (AmjObject)listView1.SelectedItems[0].Tag;

            if (obj is AmjFolder)
            {
                AmjFolder f = (AmjFolder)obj;
                curFolder = f;
                f.loadContents();
                populateAmjFolder(f, 0);
                selectedDirs.Add(curFolder.name);
            }
            else if (obj is RegularFolder)
            {
                RegularFolder f = (RegularFolder)obj;
                curFolder = f;
                f.loadContents();
                populateRegularFolder(f);
                selectedDirs.Add(curFolder.name);
            }
            else if (obj is RegularFile)
            {
                RegularFile f = (RegularFile)obj;
                f.open();
            }
            else if (obj is AmjAttribute)
            {
                AmjAttribute a = (AmjAttribute)obj;
                selectedAttributes.Add(a.value == "Unknown"?"":a.value);
                populateAmjFolder((AmjFolder)curFolder, selectedAttributes.Count);
                selectedDirs.Add("[" + a.value + "]");
            }
            this.txtPath.Text = "";
            foreach (String dir in selectedDirs)
            {
                this.txtPath.Text += dir.Contains("\\") ? dir : dir + "\\";
            }

            if (obj is RegularFolder)
            {
                File.WriteAllText(Program.SettingsFile, "RecentPath=" + this.txtPath.Text.Substring(0, this.txtPath.Text.Length - 1));
            }
        }
        private void populateAmjFolder(AmjFolder folder, int attrIndex)
        {
            listView1.Columns.Clear();
            listView1.Items.Clear();
            ImageList il = new ImageList();

            listView1.SmallImageList = il;

            if (attrIndex == folder.attributesList.Count) // populate AmjFiles here
            {
                listView1.Columns.Add("Name", 300);
                foreach (String attr in folder.attributesList)
                {
                    listView1.Columns.Add(attr);
                }

                foreach (AmjObject obj in folder.getFiles(selectedAttributes))
                {
                    if (!(obj is AmjFile))
                    {
                        continue;
                    }

                    AmjFile f = (AmjFile)obj;

                    ListViewItem item = new ListViewItem(f.name);
                    il.Images.Add(f.name, Icon.ExtractAssociatedIcon(f.path));
                    item.ImageKey = f.name;
                    foreach (String attr in folder.attributesList)
                    {
                        item.SubItems.Add(f.getAttribute(attr));
                    }
                    item.Tag = f;
                    listView1.Items.Add(item);
                }
            }
            else // Populate current attribute list
            {
                listView1.Columns.Add(folder.attributesList[attrIndex], 300);
                listView1.Columns.Add("Number of Files", 100);

                AmjAttribute  attrObj;
                ListViewItem  item;
                List <String> list;
                foreach (String attrVal in folder.getAttributeValues(attrIndex))
                {
                    attrObj = new AmjAttribute(folder.attributesList[attrIndex], attrVal);
                    item    = new ListViewItem(attrVal);

                    list = new List <string>(selectedAttributes);
                    list.Add(attrVal);
                    item.SubItems.Add(folder.getFiles(list).Count.ToString());
                    item.Tag = attrObj;
                    listView1.Items.Add(item);
                }
                attrObj = new AmjAttribute(folder.attributesList[attrIndex], "Unknown");
                item    = new ListViewItem("Unknown");

                list = new List <string>(selectedAttributes);
                list.Add("");
                item.SubItems.Add(folder.getFiles(list).Count.ToString());
                item.Tag = attrObj;
                listView1.Items.Add(item);
            }
        }