本文整理汇总了C#中INode.ResolveFile方法的典型用法代码示例。如果您正苦于以下问题:C# INode.ResolveFile方法的具体用法?C# INode.ResolveFile怎么用?C# INode.ResolveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.ResolveFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOperationTargetDirectoryFile
public static IFile GetOperationTargetDirectoryFile(INode thisNode, INode target)
{
IFile file;
if (target.NodeType == NodeType.File)
{
file = (IFile)target;
}
else if (target.NodeType == NodeType.Directory)
{
file = target.ResolveFile(thisNode.Name);
}
else
{
throw new ArgumentException("Target must be a file or directory.", "target");
}
return file;
}
示例2: CopyTo
private INode CopyTo(INode target, bool overwrite, bool deleteOriginal)
{
string targetLocalPath = null;
if (target.NodeType.IsLikeDirectory)
{
target = target.ResolveFile(this.Address.Name);
}
try
{
var service = (INativePathService)target.GetService(typeof(INativePathService));
targetLocalPath = service.GetNativePath();
}
catch (NotSupportedException)
{
}
var thisLocalPath = ((LocalNodeAddress)this.Address).AbsoluteNativePath;
if (targetLocalPath == null
|| !Path.GetPathRoot(thisLocalPath).EqualsIgnoreCase(Path.GetPathRoot(targetLocalPath)))
{
if (deleteOriginal)
{
base.DoMoveTo(target, overwrite);
}
else
{
base.DoCopyTo(target, overwrite);
}
}
else
{
target.Refresh();
if (overwrite && target.Exists)
{
try
{
target.Delete();
}
catch (FileNodeNotFoundException)
{
}
}
try
{
if (deleteOriginal)
{
try
{
File.Move(thisLocalPath, targetLocalPath);
}
catch (System.IO.DirectoryNotFoundException)
{
throw new DirectoryNodeNotFoundException(this.Address);
}
catch (System.IO.FileNotFoundException)
{
throw new FileNodeNotFoundException(this.Address);
}
}
else
{
try
{
File.Copy(thisLocalPath, targetLocalPath);
}
catch (System.IO.DirectoryNotFoundException)
{
throw new DirectoryNodeNotFoundException(this.Address);
}
catch (System.IO.FileNotFoundException)
{
throw new FileNodeNotFoundException(this.Address);
}
}
return this;
}
catch (IOException)
{
if (overwrite && target.Exists)
{
try
{
target.Delete();
}
catch (FileNotFoundException)
{
}
}
else
{
throw;
}
}
//.........这里部分代码省略.........