我有一段代码,比如 if
// last path segement can be like "binaries.x86" since
// directories can have `.` characters in them
if ((lastItemInPath = cloudFileDirectory.GetFileReference(lastPathSegment)) != null)
{
// the last path segment is a file
return lastItemInPath;
}
else if ((lastItemInPath = cloudFileDirectory.GetDirectoryReference(lastPathSegment)) != null)
{
// the last path segment is a directory
return lastItemInPath;
}
我发现这是错误的,因为第一个if
返回 true 即使lastPathSegment
它确实是一个目录。知道如何准确区分吗?