1. Blackmagic

    Blackmagic Naked Wanderer

    Dose anyone know how to unzip and overwrite existing files using C#?
     
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    From a plugin? I doubt you'd have access to do that via a plugin.
     
  3. Blackmagic

    Blackmagic Naked Wanderer

    No i have been creating a rust server manager to install rust and oxide and start the server all with in a gui everything is working fine but i just can't unzip the Oxide-Rust.zip because every option i have tried wont overwrite existing files
     
  4. LaserHydra

    LaserHydra Grenade Master Plugin Developer

    Create temporary subfolder, unzip in subfolder, delete existing files, move files from subfolder, delete subfolder.
     
  5. Blackmagic

    Blackmagic Naked Wanderer

    That was my initial idea but if i delete the RustDedicated_Data file server server won't run.
     
  6. LaserHydra

    LaserHydra Grenade Master Plugin Developer

    Only delete selected files.
     
  7. Blackmagic

    Blackmagic Naked Wanderer

    Yer that is a option but i was trying to avoid deleting and copying over 40 odd files
     
  8. LaserHydra

    LaserHydra Grenade Master Plugin Developer

    You can also instead "blacklist" certain files.
    Just delete the files one by one and ingore certain files.

    To get all files:
    Directory.GetFiles Method (System.IO)
     
  9. Blackmagic

    Blackmagic Naked Wanderer

    Never thought of that that's probably a good way to do it
     
  10. Blackmagic

    Blackmagic Naked Wanderer

    So i found a solution and i was able to unzip and move a type of file so i just had to replicate it several times
    Code (Text):
    using (ZipArchive archive = ZipFile.OpenRead(oxidepath))
                {
                    foreach (ZipArchiveEntry entry in archive.Entries)
                    {
                        if (entry.FullName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
                        {
                            entry.ExtractToFile(Path.Combine(installpath, entry.FullName), true);
                        }

                    }
                }