将二进制文件转换为zip文件 [英] convert binary to zip file

查看:689
本文介绍了将二进制文件转换为zip文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的sql数据库中有一个字段,该字段保存了二进制数据,
此二进制数据是压缩文件.
如何读取此数据并将其转换为zip文件?

Hi,
i have a field in my sql database that is saved a binary data,
this binary data is a zipped file.
how to read this data and convert it to zip file?

推荐答案

只需将数据检索为二进制文件,然后使用zip). href ="http://msdn.microsoft.com/en-us/library/system.io.binaryreader.aspx"> BinaryWriter [
Just retrieve the data as binary and then save it (with zip extension) using a BinaryWriter[^].


希望您使用ADO.net

Hope u r using ADO.net

 // Initalize connection before this
SqlCommand cmd=new SqlCommand("select zipdat from table",con); //con for sqlconnection

//zipdat is column where you stored bytes of zip file

con.Open();



byte [] zipbts=(byte[])cmd.ExecuteScalar();


File.WriteAllBytes("C\\myfile.zip",zipbts);




希望这会有所帮助

祝你好运..........




Hope this helps

best of luck..........


这篇关于将二进制文件转换为zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆