当前位置: 首页>>代码示例>>C#>>正文


C# INode.ResolveFile方法代码示例

本文整理汇总了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;
		}
开发者ID:vector-man,项目名称:Platform.VirtualFileSystem,代码行数:19,代码来源:AbstractFile.cs

示例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;
					}
				}
//.........这里部分代码省略.........
开发者ID:Euphrates-Media,项目名称:Platform.VirtualFileSystem,代码行数:101,代码来源:LocalFile.cs


注:本文中的INode.ResolveFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。