how do I Refresh "My Computer" network drives for vb 2005 data access  
Author Message
Mike Cutts





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

Since windows 2000 came out there has been annoying red "X" on My Computer's network drives.

If you click on them, they go away and the files are displayed.

In VB 2005, the mycomputer.filesystem.drives.item(n) does not refesh them and directory.getfiles("P:\") returns an error "could not find part of the path P:\"

When I double click on P: in my computer, the error goes away and I can read the files again.

This is annoying becuase I write a lot of network applications.

How can I implement code in my program to refresh drive "P:"

I just tried :

Using sw As StreamWriter = New StreamWriter("P:\temp.log")

That does not work also...



Visual Basic16  
 
 
MCH1989





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

I am getting the same problem but in VB6.

Can anyone suggest a way to refresh the database on form load


 
 
Mike Cutts





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

The only workaround I have is to use URI addresses like \\server\share instead of inactive drive mappings. It is really annoying having to code my programs to trap a "\" in the drive name field and ask for the address. Looks like we are stuck with this one.

Mike


 
 
gudel





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

It is really annoying having to code my programs to trap a "\" in the drive name field and ask for the address

All my programs use the unc path, never mapped drive. it never asks for the address either. The only thing that cause problem is that if one of the machine got rebooted and the share has password, one will get error accessing the unc path. It seems that the work around is to run "net use" first to map the drive.


 
 
Amr Ouf





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

I think this link will be helpfull.

http://visualbasic.ittoolbox.com/groups/technical-functional/visualbasic-l/how-to-refresh-online-database-path-880741

Hope this can help!

If it's the right answer to your question please mark it as Answer.

Best Regards,



 
 
Amr Ouf





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

Try this:

Dim prcProcess As New System.Diagnostics.Process

With prcProcess

'DELETE NETWORK DRIVE

With .StartInfo

.FileName = "net.exe"

.Arguments = "use x: /delete"

.UseShellExecute = False

.CreateNoWindow = True

End With

Call .Start() 'Drive is unmounted

Call .WaitForExit()

'CREATE NETWORK DRIVE

With .StartInfo

.FileName = "net.exe"

.Arguments = "use x: \\192.168.0.3\Mp3s"

.UseShellExecute = False

.CreateNoWindow = True

End With

Call .Start() 'Drive is mounted

Call .WaitForExit()

End With

prcProcess.Dispose()

prcProcess = Nothing

for more information about How to connect and disconnect a network drive in Windows XP please visit http://support.microsoft.com/kb/308582/en-us

Hope this can help!

Best Regards,

Amr Ouf

 
 
Mike Cutts





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

Thank you Amr.

This is like everything else in VB, a nudge in the right direction. I hope that one day they will make it as simple as system.io.net.refresh("S:")

I have another common annoying problem tonight. (I have 4 computers, 1 xp home as a server, 1 98 workstation and 2 - win 2k laptops.) When I use \\server names on my laptop or net use commands, I get "Error 71...No More Connections can be made" I think that microsoft really made a bad money decision with this "10 resource connection" limit to workstations.

I think I might end up installing linux servers for me and my customers in the future.

System.diagnostics looks interesting. I wish also that there was an quicker, easier, more organized way to find the system calls like microsoft.visualbasic.left() or system.IO.path... I spend most of my time hunting for solutions to simple problems in VB.

My other beef is with Microsoft bug reporting.... I have found bugs in XP home and I can not let microsoft know without paying them for support. There should be an easier way for the general public to tell microsoft what is not working.

Thanks again for the solutions, they are functional workarounds.

Mike


 
 
Pointer King





PostPosted: Visual Basic General, how do I Refresh "My Computer" network drives for vb 2005 data access Top

This is a C# snipet but can be converted to VB if necessary.

Call this before accessing a mapped drive.

System.Threading.Thread.Sleep(2000); // wait 2 seconds for system to catch up of loop your next hits....

This will launch the DOS Net functions and refresh the drive availability.

Downside to this method is you will get the CMD window popup. Just set the properties of the

CMD window to Close on Exit and make the window size small enough not to be annoying. This

will work, I have validated it even from a cold boot.

This method does negate the value of using drive letter associations so I will be researching a better

way so the server name/share does not need to be defined. I have always prefered drive letter association

since I create industrial applications that are implemented globally. With drive letter association the users of

the apps setup the drive association at the OS level and not the app level so the app does not care what server

it is referencing. Good luck trying to get an I.T. guy to change his server name to match your app !