效果:
1.
.
.
數據庫:
思路:
上傳:先獲取word物理地址,然後根據文件的類型判斷,然後再保存到相應的文件夾下,再把路徑插入到數據庫中。
讀取:首先根據輸入的文件名字在數據庫中查找出來文件的路徑,然後再根據路徑把文件讀取出來。
代碼:
說明:需要導入COM庫:Microsoft word 11.0 Object Library.
Page_Load( SQLString = ConfigurationManager.ConnectionStrings[ UploadButton_Click( (SqlConnection sqlcon = FullName = FileUpload1.PostedFile.FileName; FileInfo fi = name = fi.Name; type = fi.Extension; (type == || type == SavePath = Server.MapPath(); .FileUpload1.PostedFile.SaveAs(SavePath + + name); sql = + name + + type + + name + SqlCommand cmd = .label1.Text = .tb1.Text = .label1.Text = lbtn_Click( (SqlConnection sqlcon = sql = + tb1.Text.ToString() + SqlCommand cmd = cmd.CommandText = SqlDataReader sdr = ImagePath = ImagePath = sdr[ oMissing = oWord = oWord.Visible = fileName = oDoc = oWord.Documents.Open( oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, }