Can't access a mapped drive
I have mapped a directory on a home networked computer to drive Z:. At a command prompt, I can switch to drive Z: and perform a directory listing. In File Explorer the directory shows under "Network locations" as "d (\\192.168.0.103) (Z:)", where d is the mapped directory and the number within parentheses is the computer's IP address.
However in a Visual Basic program, the statement
Dim Drives() As DriveInfo = DriveInfo.GetDrives
does *not* return drive Z: as one of the drives and a statement referring to a file in Z: returns a Directory Not Found exception.
How can I access a networked drive from within Visual Basic?
Re: Can't access a mapped drive
Quote:
Originally Posted by
coffent
* There should not be a space after Z:. However if I leave it out it gets turned into a smiley face. How can I prevent emoticon substitutions?
When posting a reply (or editing an existing one) click on "Go Advanced" (for creating a new thread, I think you don't need this stage).
Under the text area is an area titled "Additional Options". Under that is a tick-box for "Disable smilies in text".
Re: Can't access a mapped drive
Thanks - one problem solved. Now for the other one :)
Re: Can't access a mapped drive
I finally solved the problem by running Visual Studio as Administrator. I don't know why this is necessary, and if anyone has an explanation I'd be glad to see it!
Re: Can't access a mapped drive
Hello,@ coffent
Follow this step,To Can't access a mapped drive
Step 1 :- Open Computer by clicking the Start button and then clicking Computer.
Step 2 :- Click Map Network Drive.
Step 3 :- In the Drive list, click any available drive letter.
Step 4 :- In the Folder box, type the path of the folder or computer, or click Browse to find the folder or computer.then Click Finish.
I hope this information will be usefull for you.
Thank You.
Re: Can't access a mapped drive
Thanks for your reply. As I said, I think I've solved the problem by simply running VB as an Administrator. Why that should be necessary I don't know (but there are many things about Windows I don't understand).
Re: Can't access a mapped drive
Quote:
Originally Posted by
coffent
Thanks for your reply. As I said, I think I've solved the problem by simply running VB as an Administrator. Why that should be necessary I don't know (but there are many things about Windows I don't understand).
Did you map the drive letter as administrator? If so the mapping only exists for the administrator account, if you are running the app as your own user then map the drive as yourself.
Re: Can't access a mapped drive
It appears I must have, even though I didn't think so. I remapped the drives being sure I was *not* an Administrator, and now VB runs under User mode. Thanks.