本文修改來源:http://www.cnblogs.com/zmgdpg/archive/2005/03/31/129758.html
效果:
數據庫:
思路:
首先保存word到數據庫:獲取上傳文件字節的大小,然後從流中讀取字節,其次把獲得的流保存到數據庫。
讀取數據庫:根據名稱查找出來數據庫中的流數據,然後用讀取器BinaryWriter讀取流文件保存到指定的目錄下面。
代碼:
Page_Load( btn_Click( name = Stream fileStream = length = [] wordData = fileStream.Read(wordData, DateTime time = SqlConnection conn = conn.ConnectionString = ConfigurationManager.ConnectionStrings[ SqlCommand cmd = cmd.Connection = cmd.CommandText = SqlParameter nameParam = SqlParameter(, System.Data.SqlDbType.VarChar, nameParam.Value = SqlParameter timeParam = SqlParameter(, System.Data.SqlDbType.DateTime, timeParam.Value = SqlParameter contentParam = SqlParameter( contentParam.Value = i = (i > Response.Write( Response.Write( btn1_Click( SqlConnection conn = conn.ConnectionString = ConfigurationManager.ConnectionStrings[ SqlCommand cmd = cmd.Connection = cmd.CommandText = + tb1.Text.ToString() + buffersize = [] outbyte = filePath = + tb1.Text + reader = fs = bw = startIndex = reval = reader.GetBytes(, startIndex, outbyte, (reval == startIndex += reval = reader.GetBytes(, startIndex, outbyte, bw.Write(outbyte, , ()reval - (reader.Read().ToString() != Response.Write( + tb1.Text + Response.Write( }