Hi,
The code works very fast in sunnyday scenarios.
But in the below scenario I am not able to execute the code successfully.
1) Mapped a drive named Z to a network path.
2) Restarted the system
3) Then executed the below code.
After restart, while trying to access the drive we will be prompted for
password. How to handle this situation .Any help appreciated.
On Monday, 4 February 2008 21:26:18 UTC+5:30, dnorrishill wrote:
> While the above method is great it is not very fast. I have created a
> method that performs the same function in a fraction of the time:
>
> public string GetUNCPath(string sFilePath)
> {
> if (sFilePath.StartsWith("\\\\"))
> return sFilePath;
>
> ManagementObject mo = new ManagementObject();
> mo.Path = new
> ManagementPath(string.Format("Win32_LogicalDisk='{0}'", sFilePath));
>
> //DriveType 4 = Network Drive
> if (Convert.ToUInt32(mo["DriveType"]) == 4)
> return Convert.ToString(mo["ProviderName"]);
> else
> return sFilePath;
>
> }
>
>
> On Jan 16, 9:55 pm, Jason <[email protected]> wrote:
> > I have found a way to get universal name path from C# manage code. I
> > like to share with all of you.
> >
> > public static string GetUniversalName(string sFilePath)
> >
> > {
> >
> > if (sFilePath == string.Empty || sFilePath.IndexOf(":") >
> > 1)
> >
> > return sFilePath;
> >
> > if (sFilePath.StartsWith("\\"))
> >
> > {
> >
> > return (new Uri(sFilePath)).ToString();
> >
> > }
> >
> > ManagementObjectSearcher searcher = new
> > ManagementObjectSearcher("SELECT RemoteName FROM
> > win32_NetworkConnection WHERE LocalName = '" + sFilePath.Substring(0,
> > 2) + "'");
> >
> > foreach (ManagementObject managementObject in
> > searcher.Get())
> >
> > {
> >
> > string sRemoteName = managementObject["RemoteName"] as
> > string;
> >
> > sRemoteName += sFilePath.Substring(2);
> >
> > return (new Uri(sRemoteName)).ToString();
> >
> > }
> >
> > return sFilePath;
> >
> > }
> >
> > On Nov 17 2007, 7:01 pm, mkweaver <[email protected]> wrote:
> >
>
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net