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


C# IDirectory.CreateDirectory方法代码示例

本文整理汇总了C#中IDirectory.CreateDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.CreateDirectory方法的具体用法?C# IDirectory.CreateDirectory怎么用?C# IDirectory.CreateDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDirectory的用法示例。


在下文中一共展示了IDirectory.CreateDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecursiveCopy

        private void RecursiveCopy(IElement srcelem, IDirectory dstdirpar)
        {
            if(srcelem.IsDirectory) {

                IDirectory srcdir  = (IDirectory) srcelem;
                IElement   dstelem = dstdirpar.GetChild(srcdir.Name); // TODO: try catch

                if(dstelem != null) {
                    throw new Exception(dstelem.FullName + " already exists.");
                }

                IDirectory dstdir = dstdirpar.CreateDirectory(srcdir.Name); // TODO: try catch

                foreach(IDirectory srcsub in srcdir.GetDirectories()) { // TODO: try catch
                    if(!_cancel) RecursiveCopy(srcsub, dstdir);
                }

                foreach(IFile srcsub in srcdir.GetFiles()) { // TODO: try catch
                    if(!_cancel) RecursiveCopy(srcsub, dstdir);
                }

            } else {

                SingleCopy((IFile) srcelem, dstdirpar);
            }
        }
开发者ID:njmube,项目名称:amazon-s3-tools,代码行数:26,代码来源:BackgroundJob.cs

示例2: StartTest

 public void StartTest()
 {
     _directoryWrap = new DirectoryWrap();
     _directoryInfoWrap = _directoryWrap.CreateDirectory(path);
     Assert.IsTrue(_directoryInfoWrap.Exists, "Directory TempTest must be created.");
 }
开发者ID:gjhwssg,项目名称:SystemWrapper,代码行数:6,代码来源:DirectoryWrapTests.cs

示例3: Directory

        public void Directory(IDirectory sdir, IDirectory ddir)
        {
            if (ddir == null || sdir == null) return;

            sdir.Source = ddir.Source = sdir;
            sdir.Destination = ddir.Destination = ddir;

            int con;

            if (sdir is LocalDirectory && ddir is LocalDirectory) con = 1;
            else {
                con = Math.Max(FtpConnections.Count(true, sdir.Url), FtpConnections.Count(false, ddir.Url));
                if (ddir is FtpDirectory) {
                    ((FtpDirectory)ddir).TransferProgress = true;
                } else if (sdir is FtpDirectory) {
                    ((FtpDirectory)sdir).TransferProgress = true;
                }
            }
            if (con == 0) con = 1;
            var list = sdir.List().Where(file => !Silversite.Services.Paths.Match(ExcludePatterns, file.RelativePath)).ToList();
            var dlist = ddir.List();
            //ddir.CreateDirectory(null);

            Parallel.ForEach<FileOrDirectory>(list, new ParallelOptions { MaxDegreeOfParallelism = con },
                (src) => {
                    FileOrDirectory dest = null;
                    lock(dlist) { if (dlist.Contains(src.Name)) dest = dlist[src.Name]; }
                    if (dest != null && dest.Class != src.Class && (src.Changed > dest.Changed || Mode == Silversite.Services.Sync.Mode.Clone)) {
                        ddir.Delete(dest);
                        dest = null;
                    }
                    if (src.Class == ObjectClass.File) { // src is a file
                        if (dest == null
                            || ((Mode == Silversite.Services.Sync.Mode.Update || Mode == Silversite.Services.Sync.Mode.Add) && src.Changed > dest.Changed)
                            || (Mode == Silversite.Services.Sync.Mode.Clone && (src.Changed > dest.Changed + dt))) {
                            var s = sdir.ReadFile(src);
                            if (s != null) {
                                using (s) {
                                    ddir.WriteFile(s, src);
                                }
                            }
                        }
                    } else { // src is a directory
                        if (dest == null) Directory((IDirectory)src, ddir.CreateDirectory(src));
                        else Directory((IDirectory)src, (IDirectory)dest);
                    }
                    lock (dlist) { dlist.Remove(src.Name); }
                });
            if (Mode != Silversite.Services.Sync.Mode.Add) {
                foreach (var dest in dlist) ddir.Delete(dest);
            }
        }
开发者ID:simonegli8,项目名称:Silversite,代码行数:52,代码来源:Sync.cs


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