本文整理汇总了C#中IDirectory.Directory方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.Directory方法的具体用法?C# IDirectory.Directory怎么用?C# IDirectory.Directory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.Directory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo
/// <summary>
/// Copy "this" directory (<paramref name="a_this"/>) to the given destination directory (<paramref name="a_destination"/>).
/// </summary>
/// <param name="a_this">"This" directory.</param>
/// <param name="a_destination">Destination directory.</param>
/// <exception cref="NullReferenceException">Thrown if <paramref name="a_this"/> is null.</exception>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="a_destination"/> is null.</exception>
public static void CopyTo(this IDirectory a_this, IDirectory a_destination)
{
#region Argument Validation
if (a_this == null)
throw new NullReferenceException(nameof(a_this));
if (a_destination == null)
throw new ArgumentNullException(nameof(a_destination));
#endregion
a_destination.Create();
foreach (var file in a_this.Files())
{
var dest = a_destination.File(file.Name);
file.CopyTo(dest);
}
foreach (var directory in a_this.Directories())
{
var dest = a_destination.Directory(directory.Name);
directory.CopyTo(dest);
}
}