关闭pdf文件并取消映射驱动器 [英] close pdf file and unmap drive

查看:57
本文介绍了关闭pdf文件并取消映射驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 在vb.net中,使用Web浏览器从网络地址中查看pdf文件,如果无法关闭程序,请解决我的问题:

Hi In vb.net used web browser for view pdf files from network adress, for close program unmap notworked , please solve my problems:

Public Sub Map_Load_UnMap(ByVal Path_SVR As String, ByVal user As String, ByVal Pasw As String, ByVal Flag_Used As String)

    If Trim(UCase(Flag_Used)) = "L" Or Trim(UCase(Flag_Used)) = "S" Then
        Dim oNet

        oNet = CreateObject("WScript.Network")
        oNet.MapNetworkDrive("", Path_SVR, False, user, Pasw)

    Else
        Exit Sub
    End If
End Sub

Public Sub UnMap_ListMap()

        Dim objNet
        Dim DriveCollection
        Dim letter_str As String

        objNet = CreateObject("Wscript.Network")
        DriveCollection = objNet.EnumNetworkDrives

        For i = 0 To DriveCollection.count - 1
            If Trim(DriveCollection(i)) = "" Then
                GoTo NN
            Else
                letter_str = CStr(DriveCollection(i))
                objNet.RemoveNetworkDrive(letter_str)
            End If
NN:
        Next

    End Sub

Private Sub Btn_Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Exit.Click

     UnMap_ListMap()
     End

 End Sub


如果在程序中未查看pdf文件btn_exit起作用,但在浏览器btn_exit中查看pdf文件错误:
此网络连接有打开的文件或有待处理的请求.


If in program not viewed pdf file btn_exit worked but if view pdf file in browser btn_exit error:
This network connection has files open or requests pending.

推荐答案

我假设您是通过在浏览器中启动PDF来打开它的?您需要启动的浏览器实例的文件句柄,以便可以将其关闭.在.NET中很容易做到这一点,您可以调用Process.Start并获取文件句柄,然后告诉它关闭.
I assume you open the PDF by launching it in the browser ? You need the file handle of the browser instance that is launched, so you can close it. That''s easily done in .NET, you can call Process.Start and get back the file handle, and then you can tell it to close.


这篇关于关闭pdf文件并取消映射驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆