本文整理汇总了C#中IPath.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IPath.ToString方法的具体用法?C# IPath.ToString怎么用?C# IPath.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPath
的用法示例。
在下文中一共展示了IPath.ToString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrivateEquals
//
// Comparison
//
private bool PrivateEquals(IPath path) {
Debug.Assert(path != null);
if (this.PathMode != path.PathMode) {
return false;
}
// A FilePath could be equal to a DirectoryPath
if (this.IsDirectoryPath != path.IsDirectoryPath) {
return false;
}
return String.Compare(this.m_PathString, path.ToString(), true) == 0;
}
示例2: Exclude
/// <summary>
/// Removes the second path from the first. E.g., Exclude("c:\users\foo\bar", "c:\users") would
/// return "foo\bar".
/// </summary>
/// <param name="FirstPathObject"></param>
/// <param name="SecondPathObject"></param>
/// <returns></returns>
public IPath Exclude(IPath SecondPathObject)
{
string SecondPath = SecondPathObject.ToString();
if (!Path.StartsWith(SecondPath))
{
return null;
}
return new Win32Path(Path.Remove(0, SecondPath.Length));
}
示例3: SelectEnumerable
public IEnumerable<object> SelectEnumerable(IPath path, object data)
{
IInterrogator interrogator = InterrogatorFactory.CreateInteregator(data.GetType());
INavigator navigator = interrogator.CreateNavigator(data, path.GetType());
if (navigator == null)
{
throw new Exception(string.Concat("Couldn't create a navigator for the path '", path.ToString(), "'."));
}
IEnumerable<object> values = navigator.SelectEnumerable(path);
navigator.Dispose();
return values;
}
示例4: TryGetAbsolutePathFrom
internal static bool TryGetAbsolutePathFrom(IAbsoluteDirectoryPath pathFrom, IPath pathTo, out string pathResult, out string failureReason) {
Debug.Assert(pathFrom != null);
Debug.Assert(pathTo != null);
Debug.Assert(pathTo.IsRelativePath);
if (pathFrom.Kind == AbsolutePathKind.DriveLetter) {
// Only work with Directory
if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; }
return TryGetAbsolutePath(pathFrom.ToString(), pathTo.ToString(), out pathResult, out failureReason);
}
//
// Special case when a relative path is asked from a UNC path like ".." from "\\Server\Share".
// In such case we cannot return "\\Server" that is not a valis UNC path
// To address this we create a temporary drive letter absolute path and do the TryGetAbsolutePathFrom() on it!
//
Debug.Assert(pathFrom.Kind == AbsolutePathKind.UNC);
var pathFromString = pathFrom.ToString();
string uncServerShareStart;
var fakePathFromString = UNCPathHelper.TranformUNCIntoDriveLetter(pathFromString, out uncServerShareStart);
Debug.Assert(fakePathFromString.IsValidAbsoluteDirectoryPath());
var fakePathFrom = fakePathFromString.ToAbsoluteDirectoryPath();
// Call me, but this time with a DriveLetter path (no risk of infinite recursion!)
string pathResultDriveLetter;
if (!TryGetAbsolutePathFrom(fakePathFrom, pathTo, out pathResultDriveLetter, out failureReason)) {
failureReason = failureReason.Replace(UNCPathHelper.FAKE_DRIVE_LETTER_PREFIX, uncServerShareStart);
pathResult = null;
return false;
}
Debug.Assert(pathResultDriveLetter != null);
Debug.Assert(pathResultDriveLetter.Length > 0);
Debug.Assert(pathResultDriveLetter.StartsWith(UNCPathHelper.FAKE_DRIVE_LETTER_PREFIX));
pathResult = UNCPathHelper.TranformDriveLetterIntoUNC(pathResultDriveLetter, uncServerShareStart);
return true;
}
示例5: FilterPath
public string FilterPath(IPath info) {
return info == null ? null : FilterPath(info.ToString());
}
示例6: Combine
public IPath Combine(IPath SecondPath)
{
return new Win32Path(System.IO.Path.Combine(Path, SecondPath.ToString()));
}
示例7: IsAudioPath
private bool IsAudioPath(IPath relativeTargetDir)
{
var path = relativeTargetDir.ToString().Substring(2);
return _audioPaths.Any(x => path.StartsWith(x, StringComparison.CurrentCultureIgnoreCase));
}
示例8: FilterPath
public string FilterPath(IPath info) => info == null ? null : FilterPath(info.ToString());
示例9: DeleteParentFilesIfExists
static void DeleteParentFilesIfExists(IPath path, IAbsoluteDirectoryPath backupPath) {
while (path.HasParentDirectory) {
path = path.ParentDirectoryPath;
var s = path.ToString();
if (File.Exists(s)) {
File.Delete(s);
break;
}
if (path.Equals(backupPath))
break;
}
}
示例10: TryGetAbsolutePathFrom
internal static bool TryGetAbsolutePathFrom(IAbsoluteDirectoryPath pathFrom, IPath pathTo, out string absolutePath, out string failureMessage)
{
//Argument.IsNotNull(nameof(pathFrom), pathFrom);
//Argument.IsNotNull(nameof(pathTo), pathTo);
//Debug.Assert(pathTo.IsRelativePath);
if (pathFrom.Type == AbsolutePathType.DriveLetter)
{
// Only work with Directory
if (pathTo.IsFilePath)
{
pathTo = pathTo.ParentDirectoryPath;
}
return TryGetAbsolutePath(pathFrom.ToString(), pathTo.ToString(), out absolutePath, out failureMessage);
}
//Debug.Assert(pathFrom.Kind == AbsolutePathKind.UNC);
string uncServerShareStart;
string pathResultDriveLetter;
var pathFromString = pathFrom.ToString();
var fakePathFromString = UncPathHelper.ConvertUncToDriveLetter(pathFromString, out uncServerShareStart);
var fakePathFrom = fakePathFromString.ToAbsoluteDirectoryPath();
//Debug.Assert(fakePathFromString.IsValidAbsoluteDirectoryPath());
if (!TryGetAbsolutePathFrom(fakePathFrom, pathTo, out pathResultDriveLetter, out failureMessage))
{
failureMessage = failureMessage.Replace(UncPathHelper.FakeDriveLetterPrefix, uncServerShareStart);
absolutePath = null;
return false;
}
//Debug.Assert(pathResultDriveLetter != null);
//Debug.Assert(pathResultDriveLetter.Length > 0);
//Debug.Assert(pathResultDriveLetter.StartsWith(UNCPathHelper.FAKE_DRIVE_LETTER_PREFIX));
absolutePath = UncPathHelper.ConvertDriveLetterToUnc(pathResultDriveLetter, uncServerShareStart);
return true;
}
示例11: PrivateEquals
private bool PrivateEquals(IPath path)
{
if (PathType != path.PathType)
{
return false;
}
// A FilePath could be equal to a DirectoryPath
if (IsDirectoryPath != path.IsDirectoryPath)
{
return false;
}
return string.Compare(CurrentPath, path.ToString(), StringComparison.OrdinalIgnoreCase) == 0;
}