Return Directory.GetDirectoryRoot(path).Replace((), "") Throw new ArgumentException("A UNC path was passed to GetDriveLetter") Learn the most effective ways to connect a network drive to your setup, whether an office or home, to establish a secure and continuous flow of information. / Console.WriteLine(string.Format("' was not a rooted path and GetDriveLetter does not support relative paths.", / // Mapped drive pointing to \\workstation\Temp / // Example/Test paths, these will need to be adjusted to match your environment.
For Windows instructions, see How do I map a network drive in Windows To map a network drive in Mac OS X: Under the Go menu, open the Connect to Server utility.
This article explains how to map a network drive using Mac OS X. / using System.Management // Reference Mapping a network drive is a way to connect to a shared network folder, such as a share on a ReadyNAS storage system. / If a local drive path or a UNC network path are passed in, they will just be returned. / A static class to help with resolving a mapped drive path to a UNC network path. 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:
2.- Here is where you will type in the path of the homeshare. Note: If you’re unable to map a network folder or drive, check whether the computer you’re trying to connect to is turned off, or check whether you have the correct permissions. Infoacceso Troubleshooting Map home network drive Map home network drive in Mac OS X. It’ll also display the shared folders, from which you can view and open files on the network drive. You’ll see a new window for the drive denoted by the drive letter you assigned earlier. Note: If your NAS device has a username and password, you may need to enter it to access the drive. With proper security credentials, you can map network drives and access folders on a remote PC using its drive letter rather than a UNC path.
Use a password you can remember in case other colleagues or family members need to use it. A mapped network drive can be an alternative to a UNC path and both of them can be used in Microsoft Windows Explorer, Command Prompt, or PowerShell. username and password of the computer you want to connect to. You’ll get a prompt to enter the shared network login information i.e.