private static void RemoveDuplicates(ConfigPathCollection coll)
        {
            if (coll == null)
            {
                return;
            }
            BindingList <ConfigPath> list = coll.List;

            if (list == null)
            {
                return;
            }
            if (list.Count == 1)
            {
                return;
            }
            //
            HashSet <String> u = new HashSet <string>( );

            for (int i = 0; i < list.Count; i++)
            {
                ConfigPath cp = list[i];
                //string k = cp.Type + "-" + cp.ShortCut + "-" + cp.PathDir + (cp.BaseDir != null ? @"\" + cp.BaseDir : "");
                string k = cp.Type + "-" + cp.ShortCut + "-" + cp.PathDir;
                if (!u.Contains(k))
                {
                    u.Add(k);
                    continue;
                }
                list.Remove(cp);
                i--;
            }
        }
        private static void RemoveInvalidTypes(ConfigPathCollection coll)
        {
            if (coll == null)
            {
                return;
            }
            BindingList <ConfigPath> list = coll.List;

            if (list == null)
            {
                return;
            }
            //
            for (int i = 0; i < list.Count; i++)
            {
                ConfigPath cp = list[i];
                if (cp != null)
                {
                    cp.Normalize( );
                    continue;
                }
                list.Remove(cp);
                i = -1;
            }
        }
 public ConfigPath(ConfigPath cp)
 {
     this.IsActive    = cp.IsActive;
     this.IsValid     = cp.IsValid;
     this.DirExists   = cp.DirExists;
     this.DirReadable = cp.DirReadable;
     this.DirWritable = cp.DirWritable;
     this.Type        = cp.Type;
     this.ShortCut    = cp.ShortCut;
     this.PathDir     = cp.PathDir;
     //this.BaseDir = cp.BaseDir;
 }
        public static ConfigPath NewTemplate()
        {
            // ATTENTION: THIS MUST BE NOT CHANGED "AtLeastOneDataSourceDir" ...
            ConfigPath o = new ConfigPath( )
            {
                Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                IsActive = true,
                ShortCut = (int)ConfigPath.PathTypeShortCutEnum.MyDocuments,
                //BaseDir = ConfigPathCollection.BASEDIR
            };

            o.Normalize( );
            return(o);
        }
        private static void AtLeastOneDataSourceDir(ConfigPathCollection coll)
        {
            if (coll == null)
            {
                return;
            }
            BindingList <ConfigPath> list = coll.List;

            if (list == null)
            {
                return;
            }
            //
            for (int i = 0; i < list.Count; i++)
            {
                ConfigPath cp = list[i];
                if (cp.Type == (int)ConfigPathTypeEnum.DataStores)
                {
                    return;
                }
            }
            list.Add(ConfigPathCollection.NewTemplate( ));
        }
        public static ConfigPathCollection NewCollectionTemplate()
        {
            ConfigPathCollection c = new ConfigPathCollection( );

            #region --- DATASTORE FOLDERS... ---
            {
                var o = ConfigPathCollection.NewTemplate( );
                c.List.Add(o);
            }
            {
                DriveInfo[] drives = DriveInfo.GetDrives( );
                foreach (DriveInfo drive in drives)
                {
                    ConfigPath o = new ConfigPath( )
                    {
                        Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                        IsActive = true,
                        ShortCut = (int)ConfigPath.PathTypeShortCutEnum.Custom,
                        PathDir  = drive.Name + "temp"
                    };
                    o.Normalize( );
                    c.List.Add(o);
                }
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.ApplicationData,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.CommonApplicationData,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.CommonDesktopDirectory,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.CommonDocuments,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.Desktop,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.DesktopDirectory,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.LocalApplicationData,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.MyDocuments,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            {
                ConfigPath o = new ConfigPath( )
                {
                    Type     = (int)ConfigPath.ConfigPathTypeEnum.DataStores,
                    IsActive = true,
                    ShortCut = (int)ConfigPath.PathTypeShortCutEnum.UserProfile,
                    PathDir  = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)
                };
                o.Normalize( );
                c.List.Add(o);
            }
            #endregion

            #region --- TEMPORARY FOLDERS... ---
            {
                DriveInfo[] drives = DriveInfo.GetDrives( );
                foreach (DriveInfo drive in drives)
                {
                    ConfigPath o = new ConfigPath( )
                    {
                        Type     = (int)ConfigPath.ConfigPathTypeEnum.Temporary,
                        IsActive = true,
                        ShortCut = (int)ConfigPath.PathTypeShortCutEnum.Custom,
                        PathDir  = drive.Name + "temp"
                    };
                    c.List.Add(o);
                }
            }
            #endregion

            return(c);
        }