![](/img/trans.png)
[英]Open Windows Explorer from VB.NET: doesn't open in the right folder
[英]VB.net closing folder - doesn't work when IE open
我遇到的奇怪問題。
我正在使用以下代碼查找打開的文件夾並關閉它
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打開后,出現以下錯誤:
Microsoft.VisualBasic.dll中發生了類型為'System.MissingMemberException'的未處理的異常
附加信息:找不到類型為“ HTMLDocumentClass”的公共成員“文件夾”。
我個人不使用IE,但是我的用戶可能這樣做,如果我進行部署,這會引起問題。 有人有解決方法或建議嗎?
這是預期的行為,您將選擇任何打開的資源管理器或Internet資源管理器窗口。 您可以通過添加引用來處理這個mshtml
在Microsoft HTML對象庫,也SHDocVw
在Microsoft Internet控制。
Add Reference > COM > Type Libraries > Microsoft HTML Object Library
Add Reference > COM > Type Libraries > Microsoft Internet Controls
Dim sh As New SHDocVw.ShellWindows
For Each item In sh
If Not TypeOf item.Document Is mshtml.HTMLDocument Then
MessageBox.Show("it is not an IE window! " + item.Path())
Else
MessageBox.Show("it is an IE window!" + item.Path())
End If
Next item
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.