acessing network shared folder with a username and password string in vb.net

Posted by Irene on Stack Overflow See other posts from Stack Overflow or by Irene
Published on 2010-04-28T07:13:31Z Indexed on 2010/04/28 7:23 UTC
Read the original article Hit count: 386

Filed under:

i am using the following code to read the details from a network folder which is restricted for only one user

shell("net use q: \\serveryname\foldername /user:admin pwrd", AppWinStyle.Hide, True, 10000)
            Process.Start(path)
shell("net use q: /delete")

when i run this to open any pdf or jpg or any other files except word/excel/powerpoint, everything is working fine. but the problem comes only when i access a word file.

in the step one, i am giving permission to access the word file. in the step two, word file is open. in the third, i am deleting the q drive.

the problem is the word file is still open. so i am getting a dos window, saying that "some connections of still connected or searching some folders, do you want to force disconnect" please help.... how to access a word file (editable files) providing user name and password from the code and at the same time he shoud not have access to any other folders directly.

© Stack Overflow or respective owner

Related posts about .NET