public Boolean BuildTreeFromPathData(String RootPath, TreeNode NodeParent)
 {
     try
     {
         NodeParent.Tag = RootPath;
         foreach (string fil in System.IO.Directory.GetDirectories(RootPath).OrderBy(f => f))
         {
             ImageList.Images.Add(fil, FileIcon.GetLargeIcon(fil));
             System.GC.Collect();
             NodeParent.Nodes.Add(fil, new DirectoryInfo(fil).Name);
             BuildTreeFromPathData(fil, NodeParent.LastNode);
         }
         return(true);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.ToString());
         //MessageBox.Show(ex.ToString() + "Build");
         return(false);
     }
 }
        public Bitmap addImage(string strPath, string strCurrentDir)
        {
            string strFilPath = strPath;

            try
            {
                if (OSIco != null)
                {
                    if (System.IO.Directory.Exists(strPath) == true && (new DirectoryInfo(strPath)).Name.EndsWith("‰ƒ"))//DrivePath
                    {
                        return(DriveIcon(strPath));
                    }
                    if (System.IO.Directory.Exists(strPath) == true && strPath == strCurrentDir)//Open Directory
                    {
                        return(com.prepareImage(Bitmap.FromHicon(OSIco[68].Handle), FollowPallet));
                    }
                    if (System.IO.Directory.Exists(strPath) == true && strPath != strCurrentDir)//Directory
                    {
                        return(com.prepareImage(Bitmap.FromHicon(OSIco[69].Handle), FollowPallet));
                    }
                    Int32 intIconIndex;
                    if (strPath.Contains(',') && Int32.TryParse(strPath.Split(',').Last(), out intIconIndex))                       //Icon Extraction
                    {
                        return(Bitmap.FromHicon(TsudaKageyu.IconUtil.Split(new Icon(strPath.Split(',')[0]))[intIconIndex].Handle)); //, true);
                    }
                    if (!System.IO.File.Exists(strPath))                                                                            //Error
                    {
                        return(com.prepareImage(Bitmap.FromHicon(OSIco[52].Handle), FollowPallet));
                    }
                    if (strPath.EndsWith("lnk", true, System.Globalization.CultureInfo.CurrentUICulture))
                    {
                        Bitmap   ink = new Bitmap(1, 1);
                        Graphics g   = Graphics.FromImage(ink);
                        ShortCut lnk = new ShortCut(strPath);
                        if (ink.Width + ink.Height == 2)
                        {
                            ink = new Bitmap(addImage(com.toSystemPath(lnk.TargetFile), ""), 32, 32);
                        }
                        if (!(File.ReadAllLines(strFilPath).Count() >= 5 && File.ReadAllLines(strFilPath)[4] == "Sys"))
                        {
                            g.DrawImage(Bitmap.FromHicon(OSIco[29].Handle), 0, ink.Height - OSIco[29].Height);
                        }
                        return(com.prepareImage(ink, FollowPallet));
                    }
                    if (strPath.EndsWith("U95exe", true, System.Globalization.CultureInfo.CurrentUICulture) || strPath.EndsWith("U95com", true, System.Globalization.CultureInfo.CurrentUICulture))
                    {
                        return(null);// Properties.Resources.Attention;
                    }
                    if ((ViewType == ExplorerType.ControlPanel && strPath.EndsWith("cpl", true, System.Globalization.CultureInfo.CurrentUICulture)) || strPath.EndsWith("exe", true, System.Globalization.CultureInfo.CurrentUICulture))
                    {
                        TsudaKageyu.IconExtractor i = new TsudaKageyu.IconExtractor(strPath); // addImage(CDrivePath & File.ReadAllLines(strPath).First, "")
                                                                                              // MessageBox.Show(strPath)
                        if (i.Count > 0)
                        {
                            return(com.prepareImage(i.GetIcon(i.Count - 1).ToBitmap(), FollowPallet));
                        }
                        else
                        {
                            return(com.prepareImage(Bitmap.FromHicon(OSIco[70].Handle), FollowPallet));  // Return setSetting.OSIco(Int(ReadAllLines(strPath).Last)).ToBitmap
                        }
                    }
                    if (strPath.EndsWith(".U95ico", true, System.Globalization.CultureInfo.CurrentUICulture))
                    {
                        return(com.prepareImage(strPath));
                    }
                    if (strPath.EndsWith(".txt", true, System.Globalization.CultureInfo.CurrentUICulture))
                    {
                        return(com.prepareImage(Bitmap.FromHicon(OSIco[42].Handle), FollowPallet));
                    }
                    if (strPath.EndsWith(".msi", true, System.Globalization.CultureInfo.CurrentUICulture))
                    {
                        return(com.prepareImage(Bitmap.FromHicon(OSIco[46].Handle), FollowPallet));
                    }
                    return(com.prepareImage(Bitmap.FromHicon(OSIco[0].Handle), FollowPallet));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            if (strFilPath.EndsWith(".jpg", StringComparison.CurrentCultureIgnoreCase))
            {
                return(ScaleImage(strFilPath, 48, 48));
            }
            if ((OSIco == null) || OSIco.Count() < 1)
            {
                return((Bitmap)FileIcon.GetLargeIcon(strFilPath));
            }
            else
            {
                return(null);
            }
        }