我遇到的奇怪问题的排序。使用VB.net关闭文件夹 - 当IE打开时不起作用
林下面的代码找到一个打开的文件夹并将其关闭
Dim sh = CreateObject("shell.application")
For Each item In sh.Windows
If item.document.folder.self.Path = DBFolder Then
item.Quit()
End If
Next
这里的怪异的一部分,它按预期工作,除非Internet Explorer窗口已打开。与IE浏览器打开我得到以下错误:
An unhandled exception of type 'System.MissingMemberException' occurred in Microsoft.VisualBasic.dll
Additional information: Public member 'folder' on type 'HTMLDocumentClass' not found.
我个人不使用IE浏览器,但我的用户很可能这样做这是要引起问题,如果我部署。有没有人有解决方法或建议?
打开**选项严格在**和修正错误。然后摆脱旧的vb6 ** CreateObject **。然后修复这些错误,应该是“迟绑定”错误。使用CreateObject的替代品,它是System.Activator。 CreateInstance方法。 – Codexer
@Codexer他的问题是他正在循环浏览器和Internet Explorer窗口。 IE窗口没有“item.document.folder”成员。 –
我知道确切的问题是什么,但他需要先解决其他问题。如果他这样做,那么调试器会向他显示问题。你错过了我的评论... – Codexer