日期:2014-05-17 浏览次数:20839 次
//word文件上传按钮
private void button2_Click(object sender, EventArgs e)
{
OleDbConnection Conn;
Conn = new OleDbConnection(StartWindow.StrConn);
Conn.Open();
string location = textBox1.Text;
string[] argLocation= location.Split(new Char[] {'\\'});
int i = argLocation.Length;
linkLabel1.Text = argLocation[i-1];
System.IO.FileStream fs = new System.IO.FileStream(@location,System.IO.FileMode.Open);
fs.Position = 0;
byte[] content = new byte[fs.Length];
fs.Read(content, 0, (int)fs.Length);
fs.Close();
// OleDbDataAdapter da;
string strUpdate = "update Base_TAnswerFile set DeviationTable='" + content + "',ItemInformation='招标项目信息'";
OleDbCommand cmd = new OleDbCommand(strUpdate,Conn);
cmd.CommandText = strUpdate;
cmd.ExecuteNonQuery();
cmd.Dispose();
Conn.Close();
Conn.Dispose();
Conn.Close();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//读取二进制文件转化为word文档
string filePath = "E:\\test.doc";
string fileName = filePath;
if (System.IO.File.Exists(fileName))
{
System.IO.File.Delete(fileName);
&