请教个关于二进制的问题 我将文件(office文档或图片)用image的方式存入数据库,请教怎样把他们取出来时还原成文件的形式呢?请教,谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下载(二进制)(这是将数据绑定在DG,模板列上放了隐藏域存二进制数据) private void repClass_ItemCommand(object source, RepeaterCommandEventArgs e) { if(e.CommandName=="download") { System.Web.UI.HtmlControls.HtmlInputHidden rd=new System.Web.UI.HtmlControls.HtmlInputHidden (); rd=(System.Web.UI.HtmlControls.HtmlInputHidden)e.Item.FindControl("Hidden1");//将二进制数据读出 int id=Convert.ToInt32(rd.Value); DocumentInfo info =SignUp.Component.Bll.Class.Document.GetByID(id); int size=Convert.ToInt32(info.strformat_content.Length); byte[] f=new byte[size]; f=info.strformat_content; Random ran = new Random(); string strfile = DateTime.Now.ToString(@"yyyyMMddHHmmss") + ran.Next(100,999)+"."+info.strfileHZ; //string filename=info.strFile_Info; string newfile=Server.MapPath("../UpLoad/"+strfile); FileStream fs=new FileStream(newfile,FileMode.CreateNew); fs.Write(f,0,size); fs.Close(); Response.Redirect("../UpLoad/"+strfile); } 急!asp.net无法显示页面 高手请进, 全局变量 已经分组查询了,但在子查询中返回某字段值相同的记录 三层结构中实体类该如何使用? vs2005中javascript代码的问题 孟子E章 和高手请进。急!! session最大值的问题 DropDownList 控件邦定问题 asp页面与sql数据库的数据访问与显示 c#.net 2005 asp.net 开发。在javascript中取消按键事件 WORD,PDF文件在IE中打开问题?
private void repClass_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if(e.CommandName=="download")
{
System.Web.UI.HtmlControls.HtmlInputHidden rd=new System.Web.UI.HtmlControls.HtmlInputHidden ();
rd=(System.Web.UI.HtmlControls.HtmlInputHidden)e.Item.FindControl("Hidden1");//将二进制数据读出
int id=Convert.ToInt32(rd.Value);
DocumentInfo info =SignUp.Component.Bll.Class.Document.GetByID(id);
int size=Convert.ToInt32(info.strformat_content.Length);
byte[] f=new byte[size];
f=info.strformat_content;
Random ran = new Random();
string strfile = DateTime.Now.ToString(@"yyyyMMddHHmmss")
+ ran.Next(100,999)+"."+info.strfileHZ;
//string filename=info.strFile_Info;
string newfile=Server.MapPath("../UpLoad/"+strfile);
FileStream fs=new FileStream(newfile,FileMode.CreateNew);
fs.Write(f,0,size);
fs.Close();
Response.Redirect("../UpLoad/"+strfile);
}