Laden...

Forenbeiträge von Art75 Ingesamt 2 Beiträge

16.06.2021 - 11:44 Uhr

Huhu,

mit


ZipFile.CreateFromDirectory(startPath, zipPath);

Kann man ja sehr einfach aus c# Zip-Files erstellen.

Leider finde ich keine Möglichkeit des ZIP zu splitten.

Ich habe zB 1 GB Daten und möchte daraus 10 x 100MB ZIPs erzeugen.

file.zip
file.z01
file.z02

usw usw

Halt einfach ein ZIP-Archiv das in mehere Teile geteilt ist (aber keines der Teile funktioniert alleine).
7Zip usw können das, ich möchte das in c# und wenn es geht mit "Hausmitteln".

Jemand eine Idee (zur Not auch mit Einbundung von externen Ressourcen)?

Danke euch!

16.06.2021 - 11:36 Uhr

Huhu,

du kannst die Listen glaube ich mit Union, Interselect, Except vergleichen...

Hier ein Beispiel, das wird nicht funktionieren, aber vom Grundsatz sollte es Klarheit schaffen.

Siehe auch hier:



        public static List<md5list> md5lines1 = new List<md5list>();
        public static List<md5list> md5lines2 = new List<md5list>();
            

            // Step 1: Create a union list from the first and the second (only single entries. Duplicates will be removed automatically)
            var unionList = md5lines1.Union(md5lines2, new DoCompare());
            // Step 2: Create a list with the entries, which are in both lists 
            var intersectList = md5lines1.ToList().Intersect(md5lines2, new DoCompare());
            // Step 3: Get the entries which only in the union list and not in the intersect list
            var exceptList = unionList.Except(intersectList);
            // Step 4: Create a list with entries only in file1
            var onlyFile1 = exceptList.Except(md5lines2);
            // Step 4: Create a list with entries only in file2
            var onlyFile2 = exceptList.Except(md5lines1);

        public class md5list
        {
            public string Hash { get; set; }

            public string Path { get; set; }

            public override string ToString()
            {
                return "Hash: " + Hash + " Path: " + Path;
            }
        }

        public class DoCompare : IEqualityComparer<md5list>
        {
            public bool Equals(md5list md5lines1, md5list md5lines2)
            {
                if (md5lines1.Hash == md5lines2.Hash && md5lines1.Path == md5lines2.Path)
                {
                    return true;
                }
                return false;
            }
            public int GetHashCode(md5list obj)
            {
                return obj.Hash.GetHashCode();
            }

        }


Das ist denke ich die schnelle Lösung...

Ich hoffe das war jetzt nicht komplett am Thema vorbei...

Grüße,
Art