Mapped Drive

Joined
Jan 15, 2009
Messages
21
Programming Experience
5-10
I have a vb.net app that reads from text files and a database over a network connection. On a couple of the computers, it pops up with error messages saying the drive can not be found.

The weird thing is, if I go to My Computer and open up the folder and then close it out and start the program again, everything goes fine.

To solve this I just run a process to open that directory at startup:
Dim newprocess as Process = Process.Start("explorer.exe", "F:\test\")

That works fine, but it is just bothersome to close the folder every time. I am hoping there is a better way to do this. Thanks
 
I'm not sure if this is some kind of authentication issue, and you maybe manually have to open it first.. (im just guessing here).

I assume you have the "stay connected" box ticked etc?


You could maybe disconnect and then remap the drive from your program using the "net use" command before accessing the drive and see if that helps?

Just an idea.
 
I ended up using this code and haven't had any problems with it so far.

Dim ayo As New IO.DriveInfo("F")
Do Until ayo.IsReady = True
'do nothing
Loop
 
You may have better luck going to the share directly instead of using it's drive letter if you can. I.e. instead of f:\ use \\ServerName\ShareName. .Net seems to like that better in my experience.
 
Only issue is if for some reason the drive never becomes "ready" and your stuck in a loop. I use something like this comparable to yours:

VB.NET:
Dim mySettingsDrive As New IO.DriveInfo("F:")
Dim x As Integer
For x = 0 To 9
     If mySettingsDrive.IsReady = True Then Exit For
     Threading.Thread.Sleep(1000)
Next

So I wait up to 10 seconds for the drive to become ready and if it's not I move on.
 
Last edited:
on the same thought process anyone know of a way to do this exact same thing but with a network share? (i.e. \\MyServer\MyShare )

I usually point all my files to the shares instead of mapped drives but sometimes I run into the same issue with the drive not being ready.
 
on the same thought process anyone know of a way to do this exact same thing but with a network share? (i.e. \\MyServer\MyShare )

I usually point all my files to the shares instead of mapped drives but sometimes I run into the same issue with the drive not being ready.


Maybe like the above code, but maybe just try and open it, and if it fails catch the error and try again? (for 10 seconds).

I've never had this problem from the limited code I have used involving mapped drives luckily.
 
Back
Top