2012-03-07, 02:00 AM
Trying to solve a problem in the nDroid service when users have videos/music media on network shares I find I can't enumerate the directories when the path is the root of a mapped network drive.
Using this code where foldername is Z:\...I catch a DirectoryNotFoundException logged as According to the MSDN page for Directory.GetDirectories that exception reason is "The specified path is invalid (for example, it is on an unmapped drive)." but the drive IS mapped and the nDroid service has permission to access it.
The weird thing is what I'd expect to fail is passing the sharename into that function (\\myserver\music\) but that actually DOES work. :confused:
This is only happening for mapped networked drives - D:\ for example (which is local), works fine.
Anybody seen anything like this? Got a cure?
Using this code where foldername is Z:\
Code:
List<string> folderList = null;
try
{
folderList = new List<string>(Directory.GetDirectories(folderName, "*.*", SearchOption.TopDirectoryOnly));
}
catch (DirectoryNotFoundException dnfe)
{
Log.LogException("GetMediaFolderContents() - enumerating folders", dnfe);
return "";
}
Code:
GetMediaFolderContents() - enumerating folders threw exception: Could not find a part of the path 'Z:\'. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
at System.IO.Directory.GetDirectories(String path, String searchPattern, SearchOption searchOption)
The weird thing is what I'd expect to fail is passing the sharename into that function (\\myserver\music\) but that actually DOES work. :confused:
This is only happening for mapped networked drives - D:\ for example (which is local), works fine.
Anybody seen anything like this? Got a cure?