![]() ![]() If (originalPath.Length > 2 & originalPath = ':') StringBuilder sb = new StringBuilder(512) Public static string GetUNCPath(string originalPath) Public static extern int WNetGetConnection( If the absolute path cannot be converted to a UNC path, the absolute path is returned unchanged. This method accepts an absolute path (which could be on a mapped drive or on a local drive) and returns the equivalent UNC path (if exists). ![]() NET framework without needing to drill down into the Windows API, but until I find a better solution (or someone points out a better way in the comments here), I’ll be documenting this for others who might need it and for future reference. True, it would be better if this could be done reliably with the. The solution I found that always worked across multiple environments involved the use of PInvoke and a dll import. ![]() This might have been because I was working from a VM or maybe some other OS issue. The type initializer for ‘’ threw an exception. However, I found most of them to be incomplete and/or full of errors.įor example, my attempts to do this with the ManagementObject and ManagementPath classes always failed with an exception like: There are a number of resources out there that attempt to explain how to get the network path of a mapped drive letter or path.
0 Comments
Leave a Reply. |