具体代码如下所示, 代码为 一个 表的 currentchanged 事件
思路为: 某表被选择的当前行改变之后, 根据表中某列的值,找到某加密文件,解压后 在 webbrowser中显示出来,同时记下 该文档名字和位置,改变所显示的文件后,同时把上一显示文件删除
目前存在的问题: 1 打开过的文件不能被删除, 2 excel文档上面的菜单,只有第一次能显示出来, 切换文档后,excel菜单消失,只能重新打开foxtable 后才能再次显示,同样的,只能显示一次
不知道从下面的代码中能不能找到问题
If e.Table.Current Is Nothing Then '如果Current为Nothing
Return '则返回
End If
Dim fileDesc As String = e.Table.Current("描述")
Dim fileFullDir As String = e.Table.Current("文件完整路径")
'MessageBox.show(fileFullDir)
Dim web As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
web.OfficeToolBar = True
If fileDesc = "文件" Then
'MessageBox.show( System.Web.HttpUtility.UrlDecode(web.Address) & " " & fileFullDir)
Dim jiemiHouAddress As String = System.Web.HttpUtility.UrlDecode(web.Address)
jiemiHouAddress = jiemiHouAddress.Replace("/","\")
Dim tempFileName As String = Functions.Execute("getTmepFileNameByEtFileName",fileFullDir)
If jiemiHouAddress.EndsWith(tempFileName) =False Then
Dim lowerJiemiHouAddress As String = jiemiHouAddress.ToLower()
If (lowerJiemiHouAddress.EndsWith(".xls") OrElse lowerJiemiHouAddress.EndsWith("xlsx") OrElse lowerJiemiHouAddress.EndsWith("csv") OrElse lowerJiemiHouAddress.EndsWith("doc") OrElse lowerJiemiHouAddress.EndsWith("docx")) _
AndAlso oDocument IsNot Nothing Then
try
'oDocument.cancel
oDocument.save
oDocument.Saved = True
Catch ex As Exception
'MessageBox.Show("追加数据失败")
End Try
try
oDocument.close
Catch ex As Exception
'MessageBox.Show("追加数据失败")
End Try
End If
try
oDocument.delete
Catch ex As Exception
'MessageBox.Show("追加数据失败")
End Try
Functions.Execute("jiemiFile",fileFullDir, tempFileName )
Dim ifo As New FileInfo(tempFileName)
'ifo.ReadOnly = True
ifo.Hidden = True
try
Dim webBasecontrol As Object = web.basecontrol
webBasecontrol.Navigate(tempFileName)
'web.address=tempFileName
Catch ex As Exception
'MessageBox.Show("追加数据失败")
End Try
If FileSys.FileExists(lastWebBrowserAddress) Then
FileSys.DeleteFile(lastWebBrowserAddress)
try
' FileSys.DeleteFile(lastWebBrowserAddress)
Catch ex As Exception
'MessageBox.Show("追加数据失败")
End Try
End If
lastWebBrowserAddress = tempFileName
End If
Else
lastWebBrowserAddress = Nothing
'web.Address = Nothing
web.Address = "about:blank"
End If