Thursday, January 24, 2008

Get UNC from mapped drives

Here is modified method of this original one, that returns UNC path.
Example:
Input: "R:\Programs";
Output: "\\CoolServer\SomeDir\Programs";

 public static string GetUniversalPath(string folderPath)
{
if (String.IsNullOrEmpty(folderPath) folderPath.IndexOf(":") > 1)
return folderPath;
if (folderPath.StartsWith(
"\\"))
{
return folderPath;
}
ManagementObjectSearcher searcher = new ManagementObjectSearcher("
SELECT RemoteName FROM win32_NetworkConnection WHERE LocalName = '" + folderPath.Substring(0, 2) + "'
");
foreach (ManagementObject managementObject in searcher.Get())
{
string remoteName = managementObject["
RemoteName"] as String;
if (!String.IsNullOrEmpty(remoteName))
{
remoteName += folderPath.Substring(2);
return remoteName;
}
}
return folderPath;
}

Wednesday, January 23, 2008

Books

I have finished these two recently. What can I say? Sometimes difficult to read, because author likes to digress from the main topic, and write a lot about various things that are not related to subject. A lot of mysticism and philosophy, but in general books are good.

Tuesday, January 01, 2008

I have just installed and played around with VS 2008 (90 days trial). Hmm… first impression is that MS made really great tool. The VSTO are also available in professional version. I have tried testing system. It looks great and can replace NUnit from my usual practice (I’m not sure yet… but it is much easier to develop and run test from single environment). In ASP.NET projects AJAX extensions are already included but not Ajax toolkit.
I’ve got long holydays (until 9th of January), so I have time to explore new features in new IDE.