internal RarImporterHelper(SevenZipExtractor Sex)
        {
            string FileName = Sex.FileName;
            _DP = Path.GetFileName(FileName);

            StringAlbumParser sa = null;
            _RootDir = Sex.GetRootDir();

            if (_RootDir != null)
            {
                sa = StringAlbumParser.FromDirectoryHelper(_RootDir);
                _RootLength = _RootDir.Path.Length;
            }

            if ((sa == null) || (sa.FounSomething == false))
                sa = StringAlbumParser.FromRarZipName(FileName);

            _Album = sa.AlbumName;
            _Artist = sa.AlbumAuthor;
            _Year = sa.AlbumYear;

            _MaxLengthWithoutRoot = (from path in Sex.SafeArchiveFileNames() let npath = ConvertFileName(path) let len = (npath == null) ? 0 : npath.Length select len).Max();
            _MaxLengthFlat = (from path in Sex.ArchiveFileData let npath = Path.GetFileName(path.SafePath()) where (!path.IsDirectory) select npath.Length).Max();
            _MaxLengthBasic = (from path in Sex.SafeArchiveFileNames() select path.Length).Max();

            if (_MaxLengthFlat > _MaxLengthWithoutRoot)
                throw new Exception("Algo Error");

            if (_MaxLengthWithoutRoot > _MaxLengthBasic)
                throw new Exception("Algo Error");
        }
        static internal StringAlbumParser FromDirectoryHelper(DirectoryHelper  dh)
        {
            if ((dh == null) || (dh.Count==0))
                return new StringAlbumParser();

            if(dh.Count==1)
                return new StringAlbumParser(dh.Path);


            int? Year = null;

            string last =dh[dh.Count-1];

            if (_DateParser.IsMatch(last))
            {
                Year = int.Parse(_DateParser.Match(last).Value);
            }

            return new StringAlbumParser(dh[dh.Count-2],last,Year);
        }
        public void DirectoryHelperTester()
        {
            string test = @"Aziz Sahmaoui\University Of Gnawa";
            string test2 = @"Aziz Sahmaoui";
            string test3 = @"Aziz Sahmaoui\University Of Gnawa\Image";
            string test4 = @"Aziz Sahmaoui\University Of Gnawa\Musique";

            DirectoryHelper dh = new DirectoryHelper(test);
            Assert.That(dh.Count, Is.EqualTo(2));
  
            DirectoryHelper dh2 = new DirectoryHelper(test2);
            Assert.That(dh2.Count, Is.EqualTo(1));

            DirectoryHelper dh3 = dh2.GetCommunRoot(dh);
            Assert.That(dh3, Is.Not.Null);
            Assert.That(dh3.Path, Is.EqualTo(@"Aziz Sahmaoui"));

            dh3 = dh.GetCommunRoot(dh2);
            Assert.That(dh3, Is.Not.Null);
            Assert.That(dh3.Path, Is.EqualTo(@"Aziz Sahmaoui"));

            dh2 = new DirectoryHelper("toto");
            Assert.That(dh2.Count, Is.EqualTo(1));
   
            dh3 = dh.GetCommunRoot(dh2);
            Assert.That(dh3, Is.Null);
   
            dh = new DirectoryHelper(test3);
            Assert.That(dh.Count, Is.EqualTo(3));

            dh2 = new DirectoryHelper(test4);
            Assert.That(dh2.Count, Is.EqualTo(3));

            dh3 = dh.GetCommunRoot(dh2);
            Assert.That(dh3, Is.Not.Null);
            Assert.That(dh3.Count, Is.EqualTo(2));
            Assert.That(dh3.Path, Is.EqualTo(test));

        }
        static internal DirectoryHelper GetRootDir(this SevenZipExtractor sze)
        {
            DirectoryHelper RootName = null;

            foreach (ArchiveFileInfo path in sze.ArchiveFileData)
            {
  
                if (path.IsDirectory)
                    continue;

                string CurRoot = Path.GetDirectoryName(path.SafePath());

                if (string.IsNullOrEmpty(CurRoot))
                    return null;

                if (RootName == null)
                {
                    RootName = new DirectoryHelper(CurRoot);
                    continue;
                }

                if (RootName.Path == CurRoot)
                    continue;

                //Ici c'est la partie compliquee on va chercher le plus grand root commun au deux directory
                RootName = RootName.GetCommunRoot(new DirectoryHelper(CurRoot));

                if (RootName == null)
                    return null;

                RootName.ContainsSubFolder = true;
            }

            return RootName;

        }
        internal DirectoryHelper GetCommunRoot(DirectoryHelper Help2)
        {
            if (Help2==null)
                return null;

            int CommunCount = 0;

            int To = Math.Min(Count,Help2.Count);

            for (int i=0; i < To; i++)
            {
                if (this[i] != Help2[i])
                    break;

                CommunCount++;
            }

            return ( CommunCount == 0) ? null : new DirectoryHelper(_Dirs,CommunCount);
        }
        internal FolderImporterHelper(string FolderName)
        {
            _Folder = FolderName;

            if (string.IsNullOrEmpty(_Folder))
            {
                _Album = string.Empty;
                _Artist = string.Empty;
                _Year =null;
                return;
            }

            _DP = Path.GetFileName(_Folder);
            StringAlbumParser sa = StringAlbumParser.FromString(_DP);

            if (!sa.FounSomething)
            {
                DirectoryHelper RootName = new DirectoryHelper(_Folder);
                sa = StringAlbumParser.FromDirectoryHelper(RootName);
            }

            _Album = sa.AlbumName;
            _Artist = sa.AlbumAuthor;
            _Year = sa.AlbumYear;
        }