void AddNodes(TreeNode current, Folder parent, bool AllTheWay, bool AddListviewItem)
        {
            List<ListViewItem> lvi = new List<ListViewItem>();
            Folder[] Folders = parent.Folders();
            for (int i = 0; i < Folders.Length; i++)
            {
                ListViewItem li = new ListViewItem(Folders[i].Name);
                li.Tag = Folders[i];
                li.SubItems.Add(Folders[i].EntryType);
                li.SubItems.Add("");
                li.SubItems.Add(Folders[i].ModifiedDate.ToString());
                li.ImageIndex = 0;
                li.Name = Folders[i].Name;
                TreeNode tn = new TreeNode(Folders[i].Name);
                tn.Name = Folders[i].Name;
                string Label = Cache.CheckCache(Folders[i].FullPath);
                if (Label != null)
                {
                    tn.Text += " | " + Label;
                    li.SubItems.Add(Label);
                }

                if (Folders[i].IsTitleIDFolder)
                {
                    if (Properties.Settings.Default.loadTIDNames)
                    {
                        if (Cache.CheckCache(Folders[i].Name) != null)
                        {
                            tn.Text += " | " + Cache.CheckCache(Folders[i].Name);
                            li.SubItems.Add(Cache.CheckCache(Folders[i].Name));
                        }
                        // Didn't find it, need to grab that shit
                        else if (!Folders[i].IsKnownFolder)
                        {
                            if (Folders[i].GameName() != null && Folders[i].GameName() != "")
                            {
                                if (!Folders[i].IsKnownFolder)
                                {
                                    Cache.AddID(Folders[i].Name, Folders[i].GameName());
                                }
                                tn.Text += " | " + Folders[i].GameName();
                                li.SubItems.Add(Folders[i].GameName());
                            }
                        }
                    }

                    if (Properties.Settings.Default.SaveIcons && (!Folders[i].IsKnownFolder || Folders[i].Name.ToLower() == "fffe07d1"))
                    {
                        // Getting the icon
                        if (!Folders[i].IsKnownFolder || Folders[i].Name.ToLower() == "FFFE07D1".ToLower())
                        {
                            if (!siL.Images.Keys.Contains(Folders[i].Name.ToUpper()))
                            {
                                // Check the cache for the icon
                                if (Cache.GetIcon(Folders[i].Name) != null)
                                {
                                    siL.Images.Add(Folders[i].Name.ToUpper(), Cache.GetIcon(Folders[i].Name));
                                    liL.Images.Add(Folders[i].Name.ToUpper(), Cache.GetIcon(Folders[i].Name));
                                    tn.ImageKey = Folders[i].Name.ToUpper();
                                    tn.SelectedImageKey = tn.ImageKey;
                                    li.ImageKey = Folders[i].Name.ToUpper();
                                }
                                else
                                {
                                    if ( Folders[i].GameName() != null && Folders[i].GameIcon() != null)
                                    {
                                        Cache.AddIcon(Folders[i].GameIcon(), Folders[i].Name);
                                        siL.Images.Add(Folders[i].Name.ToUpper(), Folders[i].GameIcon());
                                        liL.Images.Add(Folders[i].Name.ToUpper(), Folders[i].GameIcon());
                                        //treeView1.ImageList = SmallListForFATX;
                                        //listView1.SmallImageList = SmallListForFATX;
                                        //listView1.LargeImageList = LargeListForFATX;
                                        tn.ImageKey = Folders[i].Name.ToUpper();
                                        tn.SelectedImageKey = tn.ImageKey;
                                        li.ImageKey = Folders[i].Name.ToUpper();
                                    }
                                }
                            }
                            else
                            {
                                tn.ImageKey = Folders[i].Name.ToUpper();
                                tn.SelectedImageKey = tn.ImageKey;
                                li.ImageKey = Folders[i].Name.ToUpper();
                            }
                        }
                    }
                }
                // For profile folders
                else if (Properties.Settings.Default.SaveIcons)
                {
                    Image I = Cache.GetIcon(Folders[i].Name);
                    if (I != null)
                    {
                        treeView1.Invoke((MethodInvoker)delegate
                        {
                            if (!siL.Images.ContainsKey(Folders[i].Name.ToUpper()))
                            {
                                siL.Images.Add(Folders[i].Name.ToUpper(), I);
                                liL.Images.Add(Folders[i].Name.ToUpper(), I);
                            }
                            tn.ImageKey = Folders[i].Name.ToUpper();
                            tn.SelectedImageKey = tn.ImageKey;
                            li.ImageKey = Folders[i].Name.ToUpper();
                        });
                    }
                    else
                    {
                        File FILE = Folders[i].IsProfileFolder();
                        if (FILE != null)
                        {
                            I = FILE.ContentIcon();
                            if (I != null)
                            {
                                Cache.AddIcon(I, Folders[i].Name);
                                if (!siL.Images.ContainsKey(Folders[i].Name.ToUpper()))
                                {
                                    siL.Images.Add(Folders[i].Name.ToUpper(), I);
                                    liL.Images.Add(Folders[i].Name.ToUpper(), I);
                                }
                                tn.ImageKey = Folders[i].Name.ToUpper();
                                tn.SelectedImageKey = tn.ImageKey;
                                li.ImageKey = Folders[i].Name.ToUpper();
                            }
                        }
                    }
                }
                tn.ToolTipText = tn.Text;
                tn.Tag = Folders[i];

                // If we already have a treenode under the current node with
                // the same name...
                if (current.Nodes.Find(tn.Name, false).Length != 0)
                {

                }
                else
                {
                    AddNodes(tn, Folders[i], AllTheWay, false);
                    current.Nodes.Add(tn);
                }

                if (!AllTheWay && AddListviewItem)
                {
                    if (listView1.Items.Find(li.Name, false).Length == 0)
                    {
                        lvi.Add(li);
                    }
                }
            }
            listView1.Items.AddRange(lvi.ToArray());
        }
 void Search(Folder f, string SearchTerm, bool STFS, bool Deleted, bool Files, bool Folders)
 {
     if (stop)
     {
         return;
     }
     this.Invoke((MethodInvoker)delegate { this.Text = "Searching for \"" + SearchTerm + "\"" + " in " + f.FullPath; });
     foreach (File file in f.Files())
     {
         if (stop)
         {
             return;
         }
         if (Files)
         {
             if (file.Name.ToLower().Contains(SearchTerm.ToLower()) || file.SizeFriendly.ToLower().Contains(SearchTerm.ToLower()))
             {
                 AddFile(file);
             }
             else if (STFS && file.IsSTFSPackage())
             {
                 if (file.TitleName().ToLower().Contains(SearchTerm.ToLower()) || file.TitleID().ToString("X").ToLower().Contains(SearchTerm.ToLower()) || file.ContentName().ToLower().Contains(SearchTerm.ToLower()) || file.DeviceID().ToHexString().ToLower().Contains(SearchTerm.ToLower()) || file.ProfileID().ToHexString().ToLower().Contains(SearchTerm.ToLower()) || file.ConsoleID().ToHexString().ToLower().Contains(SearchTerm.ToLower()))
                 {
                     AddFile(file);
                 }
             }
         }
     }
     foreach (Folder ff in f.Folders())
     {
         if (stop)
         {
             return;
         }
         if (Folders)
         {
             if (ff.Name.ToLower().Contains(SearchTerm.ToLower()))
             {
                 AddFolder(ff);
             }
             else if(STFS)
             {
                 if (ff.GameName() != null)
                 {
                     if (ff.GameName().ToLower().Contains(SearchTerm.ToLower()))
                     {
                         AddFolder(ff);
                     }
                 }
             }
         }
         ff.ReturnDeletedEntries = Deleted;
         Search(ff, SearchTerm, STFS, Deleted, Files, Folders);
     }
 }
 private string GetNewFolderName(Folder f)
 {
     int FoldersFound = 0;
     string NewName = "New Folder";
     foreach (Folder g in f.Folders())
     {
         if (g.Name == NewName)
         {
             FoldersFound++;
             NewName = "New Folder (" + FoldersFound.ToString() + ")";
         }
     }
     return NewName;
 }
 void ResetFolderActions(Folder folder)
 {
     folder.ResetFolderAction();
     foreach (Folder f in folder.Folders())
     {
         ResetFolderActions(f);
     }
 }