Example #1
0
        public static string ExtractJet(string DataJetLocation, JetVersion jv, string StorageLocation, string Password = "******")
        {
            ZipFile zf  = ZipFile.Read(DataJetLocation);
            string  loc = Path.Combine(StorageLocation, jv.ShortHand());

            Passwords.DJ.TryGetValue(jv.ShortHand(), out var pw);
            zf.Password = Password;


            if (Password == "RETR")
            {
                zf.Password = pw;
            }
            try
            {
                zf.ExtractAll(loc);
            }
            catch (Exception) {}
            zf.Dispose();

            return(loc);
        }
Example #2
0
        public static void UpdateFileInJet(string file, string content, string DataJetLocation, JetVersion jv, string Password = "******")
        {
            ZipFile zf = ZipFile.Read(DataJetLocation);

            Passwords.DJ.TryGetValue(jv.ShortHand(), out var pw);
            zf.Password = Password;
            if (Password == "RETR")
            {
                zf.Password = pw;
            }

            zf.UpdateEntry(file, content);

            zf.Save();
            zf.Dispose();
        }
Example #3
0
        public static string GetFileFromJet(string file, string DataJetLocation, JetVersion jv, string Password = "******")
        {
            ZipFile zf = ZipFile.Read(DataJetLocation);

            Passwords.DJ.TryGetValue(jv.ShortHand(), out var pw);
            var pass = Password;

            if (Password == "RETR")
            {
                pass = pw;
            }
            if (!zf.ContainsEntry(file))
            {
                return("error");
            }

            ZipEntry ze = null;

            foreach (ZipEntry e in zf)
            {
                if (e.FileName == file)
                {
                    ze = e;
                }
            }

            var ms = new MemoryStream();

            ze.ExtractWithPassword(ms, pass);
            var bytes   = ms.ToArray();
            var content = Encoding.UTF8.GetString(bytes);

            zf.Dispose();
            ms.Dispose();
            return(content);
        }
Example #4
0
 public static void BackupDataJet(string DataJetLocation, JetVersion jv, string StorageLocation, string Name = "")
 {
     File.Copy(DataJetLocation, Path.Combine(StorageLocation, Name + jv.ShortHand() + ".jet"));
 }