private static ShareInfo FindBestShareInfoMatch(List<ShareInfo> shareInfoList, string fileName)
{
ShareInfo matched = null;
foreach (ShareInfo shareInfo in shareInfoList)
{
if (shareInfo.IsFileSystem
&& shareInfo.ShareType != ShareType.Special
&& shareInfo.MatchesPath(fileName))
{
//Store first match
if (matched == null)
{
matched = shareInfo;
}
// better match ? if so keep it
else if (matched.Path.Length < shareInfo.Path.Length)
{
if (ShareType.Disk == shareInfo.ShareType || ShareType.Disk != matched.ShareType)
{
matched = shareInfo;
}
}
}
}
return matched;
}