Extracting dgz and/or zip2 compression files stored as binary in database

StackOverflow https://stackoverflow.com/questions/22229803

  •  06-06-2023
  •  | 
  •  

سؤال

I am pulling binary data of .doc and .pdf compressed files out of a database. I need to be able to extract these preferably from the stream and then save them to a file location. I do not have the compressed file extension, but I have the compression methods. They are zip, zip2, and dgz. I have virtually no experience in the realm of compression. I have never even heard of dgz.
I can pull the data and write it to a file location, but I cannot extract it appropriately.
I would appreciate any help from someone smarter than myself.

String sql = "SELECT * FROM table WHERE id = '12345'";
DataSet ds = ExecuteQuery(sql, "Document"); //This simply queries the data base
byte[] myBytes = new byte[0];
myBytes = (byte[])ds.Tables[0].Rows[0]["document"];

// Need to extract the stream here

StreamWriter sWriter = new StreamWriter("../file.pdf");
BinaryWriter writer = new BinaryWriter(sWriter.BaseStream);
writer.Write(myBytes);
writer.Close();

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top