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


C# IDirectory.CopyTo方法代码示例

本文整理汇总了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;
        }
开发者ID:jsmunroe,项目名称:Helpers,代码行数:30,代码来源:DirectoryHelpers.cs

示例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);
     }
 }
开发者ID:andrewdavey,项目名称:openwrap,代码行数:11,代码来源:FolderRepository.cs

示例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;
            }
开发者ID:carcer,项目名称:openwrap,代码行数:18,代码来源:FolderRepository.cs


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