日期:2014-05-17 浏览次数:21201 次
FileStream fs = new FileStream("E:\\未命名站点 2\\封面说明.html", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
Byte[] byData = br.ReadBytes((int)fs.Length);
fs.Close();
string sql = "insert into thtml values(1,'@filedata')";
SqlParameter p = new SqlParameter("@filedata", byData);new SqlParameter("@filedata", SqlDbType.Image);
private void button1_Click(object sender, EventArgs e)
{ ///读取
string conn = "server=.;database=test;Uid=sa;Pwd=123 ";
string str = "select html from thtml where guid='1' ";
SqlConnection myconn = new SqlConnection(conn);
SqlDataAdapter sda = new SqlDataAdapter(str, conn);
DataSet myds = new DataSet();
myconn.Open();
sda.Fill(myds);
myconn.Close();
Byte[] Files = (Byte[])myds.Tables[0].Rows[0]["html"];
//foreach(Files[]){
// ;
//}
BinaryWriter bw = new BinaryWriter(File.Open(path1, FileMode.OpenOrCreate));
bw.Write(Files);
bw.Close();
webBrowser1.Navigate(path1);
}
@filedata
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
....