本文整理汇总了C#中IDirectory.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.CopyTo方法的具体用法?C# IDirectory.CopyTo怎么用?C# IDirectory.CopyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.CopyTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyIn
/// <summary>
/// Copy the given directory (<paramref name="a_directory"/>) into "this" directory (<paramref name="a_this"/>).
/// </summary>
/// <param name="a_this">"This" directory.</param>
/// <param name="a_directory">Directory to copy.</param>
/// <exception cref="NullReferenceException">Thrown if <paramref name="a_this"/> is null.</exception>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="a_directory"/> is null.</exception>
public static IDirectory CopyIn(this IDirectory a_this, IDirectory a_directory)
{
#region Argument Validation
if (a_this == null)
throw new NullReferenceException(nameof(a_this));
if (a_directory == null)
throw new ArgumentNullException(nameof(a_directory));
#endregion
if (!a_directory.Exists)
throw new DirectoryNotFoundException($"Directory at path \"{a_directory.Path}\" does not exist.");
if (!a_this.Exists)
throw new DirectoryNotFoundException($"Directory at path \"{a_this.Path}\" does not exist.");
var newDirectory = a_this.Directory(a_directory.Name);
a_directory.CopyTo(newDirectory);
return newDirectory;
}
示例2: Anchor
void Anchor(IDirectory packageDirectory, IDirectory anchoredDirectory)
{
var anchoredPath = anchoredDirectory.Path;
if (_useSymLinks)
packageDirectory.LinkTo(anchoredPath.FullPath);
else
{
packageDirectory.CopyTo(anchoredDirectory);
anchoredDirectory.GetFile(".anchored").WriteString(packageDirectory.Name);
}
}
示例3: Anchor
public override bool? Anchor(IDirectory packagesDirectory, IDirectory packageDirectory, string anchorName)
{
var anchoredDirectory = packagesDirectory.GetDirectory(anchorName);
if (anchoredDirectory.Exists && anchoredDirectory.IsHardLink && !SafeDelete(anchoredDirectory))
return false;
anchoredDirectory = packagesDirectory.GetDirectory(anchorName);
if (anchoredDirectory.Exists)
{
var anchorFile = anchoredDirectory.GetFile(".anchored");
if (anchorFile.Exists && anchorFile.ReadString() == packageDirectory.Name) return null;
if (!SafeDelete(anchoredDirectory)) return false;
}
packageDirectory.CopyTo(anchoredDirectory);
anchoredDirectory.GetFile(".anchored").WriteString(packageDirectory.Name);
return true;
}