public static List<TreeItem> GetNonRootData(string dir)
        {
            List<TreeItem> ls = new List<TreeItem>();


            System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(dir);


            foreach (System.IO.DirectoryInfo di in info.GetDirectories())
            {
                TreeItem root = new TreeItem();

                root.id = System.Guid.NewGuid().ToString();
                root.text = di.Name;
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = di.FullName;

                
                // Buggy & slow
                try
                {
                    root.children = false;
                    root.state = TreeItem.NodeState.leaf;

                    if ((di.Attributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden)
                        continue;

                    if (di.GetFiles().Length > 0 || di.GetDirectories().Length > 0)
                    {
                        root.children = true;
                        root.state = TreeItem.NodeState.closed;
                    }
                }
                catch (Exception ex)
                {
                    continue;
                    // Don't add these branches
                }
                

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "Directory";
                // root.a_attr.target = "_blank";
                // root.a_attr.href = "http://127.0.0.1";

                ls.Add(root);
            }


            foreach (System.IO.FileInfo fi in info.GetFiles())
            {
                if ((fi.Attributes & System.IO.FileAttributes.Hidden) == System.IO.FileAttributes.Hidden)
                    continue;

                TreeItem root = new TreeItem();

                root.id = System.Guid.NewGuid().ToString();
                root.text = fi.Name;
                root.children = false;
                root.state = TreeItem.NodeState.leaf;
                root.data = fi.FullName;

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "file";

                root.a_attr.target = "ifrmContent";
                // string uri = System.Web.HttpUtility.UrlEncode( new System.Uri(fi.FullName).AbsoluteUri );
                string urlFileName = System.Web.HttpUtility.UrlEncode(fi.FullName);
                root.a_attr.href = (System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath + "/ajax/getFileContent.ashx?file=").Replace("//","/") + urlFileName;

                ls.Add(root);
            } // Next fi

            /*
            System.IO.FileSystemInfo[] infos = di.GetFileSystemInfos();
            
            foreach (var fsi in infos)
            {

                if ((fsi.Attributes & System.IO.FileAttributes.Directory) == System.IO.FileAttributes.Directory)
                {
                    root.type = "Directory";
                }

            }
            */

            return ls;
        }
        public static List<TreeItem> GetRootData_Windows()
        {
            List<TreeItem> ls = new List<TreeItem>();

            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "Home";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = getHomePath();

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";
                ls.Add(root);
            }

            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "Desktop";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";
                ls.Add(root);
            }

            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "MyDocuments";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";
                ls.Add(root);
            }

            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "Downloads";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = getDownloadFolderPath();

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";
                ls.Add(root);
            }


            // System.IO.DriveInfo[] infos = System.IO.DriveInfo.GetDrives();

            //string[] drives = System.IO.Directory.GetLogicalDrives();
            //foreach (string str in drives)
            //{
            //    System.Console.WriteLine(str);
            //}

            foreach (System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives())
            {
                System.Console.WriteLine(di.Name);
                System.Console.WriteLine(di.DriveType);

                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = di.Name;
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = di.Name;

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = di.DriveType;

                // root.a_attr.target = "_blank";
                // root.a_attr.href = "http://127.0.0.1";
                if (di.IsReady == true)
                    ls.Add(root);


                if (di.IsReady == true)
                {
                    double freeSpace = di.TotalFreeSpace;
                    double totalSpace = di.TotalSize;
                    double percentFree = (freeSpace / totalSpace) * 100;


                    Console.WriteLine("Drive:{0} With {1} % free", di.Name, percentFree);
                    Console.WriteLine("Space Remaining:{0}", di.AvailableFreeSpace);
                    Console.WriteLine("Percent Free Space:{0}", percentFree);
                    Console.WriteLine("Space used:{0}", di.TotalSize);

                    // TotalFreeSpace
                    Console.WriteLine("  Volume label: {0}", di.VolumeLabel);
                    Console.WriteLine("  File system: {0}", di.DriveFormat);
                    Console.WriteLine("  Available space to current user:{0, 15} bytes", di.AvailableFreeSpace);
                    Console.WriteLine("  Total available space:          {0, 15} bytes", di.TotalFreeSpace);
                    Console.WriteLine("  Total size of drive:            {0, 15} bytes ", di.TotalSize);
                }

            }

            return ls;
        }
        public static List<TreeItem> GetRootData_Linux()
        {
            List<TreeItem> ls = new List<TreeItem>();
            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "Home";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = getHomePath();

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";


                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(root.data);

                if (di.Exists)
                {
                    if (di.GetFiles().Length == 0 && di.GetDirectories().Length == 0)
                    {
                        root.children = false;
                        root.state = TreeItem.NodeState.leaf;
                    }

                    if(System.IO.Directory.Exists(root.data))
                        ls.Add(root);
                }
            }

            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "Desktop";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";
                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(root.data);

                if (di.Exists)
                {
                    if (di.GetFiles().Length == 0 && di.GetDirectories().Length == 0)
                    {
                        root.children = false;
                        root.state = TreeItem.NodeState.leaf;
                    }

                    if(System.IO.Directory.Exists(root.data))
                        ls.Add(root);
                }
            }

            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "Documents";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = System.IO.Path.Combine(getHomePath(), "Documents");

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";

                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(root.data);

                if (di.Exists)
                {
                    if (di.GetFiles().Length == 0 && di.GetDirectories().Length == 0)
                    {
                        root.children = false;
                        root.state = TreeItem.NodeState.leaf;
                    }

                    if(System.IO.Directory.Exists(root.data))
                        ls.Add(root);
                }
            }

            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "Downloads";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = getDownloadFolderPath();

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "SpecialFolder";

                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(root.data);

                if (di.Exists)
                {
                    if (di.GetFiles().Length == 0 && di.GetDirectories().Length == 0)
                    {
                        root.children = false;
                        root.state = TreeItem.NodeState.leaf;
                    }

                    if(System.IO.Directory.Exists(root.data))
                        ls.Add(root);
                }
            }


            {
                TreeItem root = new TreeItem();
                root.id = System.Guid.NewGuid().ToString();
                root.text = "/";
                //root.children = System.Convert.ToBoolean(dr["HasChildren"]);
                root.children = true;
                root.state = TreeItem.NodeState.closed;
                root.data = "/";

                // root.type = 123;
                // root.type = type_t.SO;
                // root.type = (type_t)Enum.Parse(typeof(type_t), System.Convert.ToString(dr["objtype"]));
                root.type = "folder";

                System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(root.data);

                if (di.Exists)
                {
                    if (di.GetFiles().Length == 0 && di.GetDirectories().Length == 0)
                    {
                        root.children = false;
                        root.state = TreeItem.NodeState.leaf;
                    }

                    if(System.IO.Directory.Exists(root.data))
                        ls.Add(root);
                }
            }

            return ls;
        }