|
You have the following options....
1. Disconnect your previous connection to the resource first
2. Have your code use the same username and password as your previous connection
This error comes from Windows and as far as I know, there is no way around it.
(aejw)
|
|
|
|
|
To gain one more mapped drive, connect it to the IP of the server not the name
and to gain another one too, give your DNS an alias and connect throught the alias not the server name
Check this
http://support.microsoft.com/kb/173199/[^]
Hope this help
|
|
|
|
|
Thanks to aejw's work. I usesd it in my project, but unluckly my testers found it failed to map for one time and they could not reproduce it any more. It said the user has already mapped a network dirver for the same path. What a pitty!
I think maybe it will be perfect if the function WNetGetConnection is added to detect whether that network path has been mapped as a driver or not.
modified on Sunday, March 16, 2008 10:37 PM
|
|
|
|
|
Sorry... I have been meaning to update this code (when i get the time) from my site (http://www.aejw.com/) where there is a later version posted. Should it not fix the issue with the later version, it sounds like a logic fault from the calling application... You should read back if the drive is in use or try using "try{ }catch{ }".
(aejw)
|
|
|
|
|
This would be really great !
I'm looking forward to it.
Will this also be done on version on your site VB and C# ?
If help is needs, just yell
|
|
|
|
|
No problem , yes the new version will come in two flavors / articles... c# and vb.net, Each will cross link to show how c# vs vb.net API writing is compared...
and thanks, any testing will be a great aid...
(aejw)
|
|
|
|
|
Hi,
I still have your email and did not respond on it yet, I'm very sorry for that.
You said you already have a good ammount of code for the webdav part.
How far are you at the moment ?
I'm very exited about it !
Thanks.
|
|
|
|
|
I'm not able to map a http(s) drive yet, the rest works fine on the C# version from your site.
What happen is that I get the following:
Cannot map drive !!
Err Msg: No Network Provider Accepted the Given Network Path
OK, using net use on the commandline I get an 67 error, but I think this has nothing to do with it ?
|
|
|
|
|
Off the top of my head connecting a web drive needs an alternate set of API commands to be used... I am updating the class and article soon (next week or so). I will look into including this functin.
(aejw)
|
|
|
|
|
Hey,
Great code, truly was a big help for me.
Just a quick question, I'm using this code in my windows service and when my service returned an error saying the file I was trying to read was already in use by another process, I stopped my service and tried again an hour later.
When I restarted the service I got the following error:
"The local device name is already in use."
So I tried to Unmap the drive but it return this error:
"This network connection does not exist"
I was wondering if there is a work around for is...
Also the drive letter only does not work with your code, I have been able to suucessfully map to that drive letter through NetUse, and window's map network drive without issues.
|
|
|
|
|
Ok the lastest version of my class is on my site, aejw.com... This version is a little out of date, I am updating it in the next week or so. Thanks for reporting any bugs, I will do my best to sort them all out.
As for your service, it sounds like another application is maybe accessing / using a driveless "use" connection??? im not so sure. Try unmapping the share, using null as the drive value.
Please keep me posted, I really should also look into writing a demo service application (there are some ways of re-routing a service to load under a local user account).
(aejw)
|
|
|
|
|
Hi,
I am actually using your newest verison of this code, from your website.
Also, I tried unmapping using null as the drive value, but I still got the same error.
I then followed through the drive letters effected and found no other programs accessing set drive letters, or a program using a driveless connection. So, I tried using the force command on the mapping function in hopes it would go through but had no such luck.
Thanks for the response, I guess I'll just use a different drive letter, I mean its not that big of a problem for me cause the drive letters are still able to map using windows mapping.
oh one more question, is there a way of using this code to connect to the next open drive letter (say drives A:,B:,C:, and D: are in use, it than uses E:, much like the * in a Net use cmdline), if yes is there a way remembering that drive letter so it could be placed in a server log message
Andrew
|
|
|
|
|
Thank you, Thank you, Thank you!!!
I've been searching for a way to get my service to read from a mapped drive
for a few days now!! This is exactly what I needed!!
|
|
|
|
|
Unmapping a network drive that is not bind to a local drive will fail whereas the class allows the mapping of a network drive without assigning it to a local drive.
To make it work, update the zUnMapDrive() :
<br />
int i;<br />
if (ls_Drive != "")<br />
i = WNetCancelConnection2A(ls_Drive, iFlags, Convert.ToInt32(pfForce));<br />
else<br />
i = WNetCancelConnection2A(ls_ShareName, iFlags, Convert.ToInt32(pfForce));<br />
A new version of this class that already has the fix and more features can be found here[^]
- Daniel B.
-- modified at 12:01 Monday 18th June, 2007
|
|
|
|
|
I'm sorry I really should update this article... I will get it done soon.
|
|
|
|
|
I have to Thank you a lot.
|
|
|
|
|
|
If you want to write an application in VB.NET you get errors that the namespace cannot be found. Adding a reference to networkdrive.dll does not work. I compiled the class to a new DLL which can be referenced to in VB.NET projects. Enjoy it!
http://rapidshare.com/files/7669042/NetWorkDrive.dll.html (will be deleted by rapidshare if not downloaded for 45 days)
|
|
|
|
|
The DllImport of WNetRestoreConnectionW needs to specify CharSet = CharSet.Unicode to be used to reconnect single drives. Useful because DriveInfo, FileInfo and DirectoryInfo does not reconnect drives when accessing them like explorer does.
[DllImport("mpr.dll", CharSet = CharSet.Unicode)]
public static extern int WNetRestoreConnectionW(IntPtr phWnd, string psLocalDrive);
Works for reconnecting net drives like so:
int i = WNetRestoreConnectionW(IntPtr.Zero, "z:");
Hope it helps someone
|
|
|
|
|
ta mate... will sent code project an update soon with that in it...
|
|
|
|
|
Anyone got sComment to work? I need to change the name of the mounted disk instad of "myFiles on file32". Anyone know a way to do this, without finding the entry in registry and change it here?
|
|
|
|
|
Hi,
I have implemented this in a .NET 2.0 console application which works fine on my XP development PC, but the production PC is Windows 2003, which is causing me a lot of problems with security.
I have tried with the mapped PC as name, and IP and with and without user (with and without PC name)and password.
Can you help me?
|
|
|
|
|
Windows 2003 is tricky because of its server security. Have you tried putting complete domain details in the username, eg. "DOMAIN\Username"? (This commonly turns out to be peoples problems with 2003). Other wise it could be a policy restriction.
|
|
|
|
|
No i dont think about it.
it is not any problem
|
|
|
|
|
Hi,
Just wanna contribute some input, as I'm searching for answer high and low few hours ago, Am using VB version of code (which running on win 2k3) for mapping the drive and get some files from another win 2k3 server, as far as I realize, this error occur while the workstation service is stopped.
To those who are really clueless, you can restart the service at Control Panel > Administrative Tools > Services > select the services from the list and press start on the left hand portion.
For more details you can refer to the link below:
http://www.chicagotech.net/Networking/ntbemapped1.htm
Hope this helps up.
Rgds,
G
|
|
|
|