How to open a password protected shared network folder using VB.NET?

后端 未结 2 2123
不知归路
不知归路 2021-02-15 13:47

I need to open a password protected shared folder on a network to gain access to an Access 97 database. How do I open the folder and pass in the password?

2条回答
  •  星月不相逢
    2021-02-15 14:17

    one solution would be to map the network folder to an available drive letter. You could accomplish that using Windows OS commands:

    System.Diagnostics.Process.Start("net.exe", "use K: \\Server\URI\path\here /USER: " )
    

    Simply replace the username and password with the credentials you need and make sure the drive letter is available.

    To disconnect you can call

    System.Diagnostics.Process.Start("net.exe", "use /delete K:" )
    

提交回复
热议问题