本文整理汇总了C#中Path.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Skip方法的具体用法?C# Path.Skip怎么用?C# Path.Skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.Skip方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectory
public IDirectory GetDirectory(string directoryPath)
{
directoryPath = EnsureTerminatedByDirectorySeparator(directoryPath);
var resolvedDirectoryPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(CurrentDirectory,directoryPath));
var path = new Path(resolvedDirectoryPath);
var pathSegments = new Path(resolvedDirectoryPath).Segments;
var root = pathSegments.First();
return pathSegments
.Skip(1)
.Aggregate((IDirectory)GetRoot(path.IsUnc ? string.Format("{0}{0}{1}", System.IO.Path.DirectorySeparatorChar, root) : root),
(current, segment) => current.GetDirectory(segment));
}
示例2: GetName
public override string GetName(Path path)
{
if (!path.Any()) throw new ArgumentException("Parameter 'path' cannot be empty.");
return "[" + path.First() + "]" + type.GetName(new Path(path.Skip(1)));
}
示例3: GetFile
public IFile GetFile(string filePath)
{
var resolvedFilePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(CurrentDirectory, filePath));
var pathSegments = new Path(resolvedFilePath).Segments;
var ownerFolder = pathSegments
.Skip(1).Take(pathSegments.Count()-2)
.Aggregate((IDirectory)GetRoot(pathSegments.First()),
(current, segment) => current.GetDirectory(segment));
return ownerFolder.GetFile(pathSegments.Last());
}
示例4: GetDirectory
public IDirectory GetDirectory(string directoryPath)
{
directoryPath = EnsureTerminatedByDirectorySeparator(directoryPath);
var resolvedDirectoryPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(CurrentDirectory,directoryPath));
var path = new Path(resolvedDirectoryPath);
var rootPath = System.IO.Path.GetPathRoot(path);
if (!path.IsUnc &&
rootPath.Length > 0 &&
(rootPath[rootPath.Length-1] == System.IO.Path.DirectorySeparatorChar ||
rootPath[rootPath.Length-1] == System.IO.Path.AltDirectorySeparatorChar))
rootPath = rootPath.Substring(0,rootPath.Length - 1);
var root = GetRoot(rootPath);
IEnumerable<string> pathSegments = new Path(resolvedDirectoryPath).Segments;
if (path.IsUnc || rootPath == pathSegments.First())
pathSegments = pathSegments.Skip(1);
return pathSegments
.Aggregate(root,
(current, segment) => current.GetDirectory(segment));
}