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


C# Directory.Add方法代码示例

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


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

示例1: CreateMetaDirectory

        public IDirectory CreateMetaDirectory(IDirectory parentDirectory, IDirectory directory)
        {
            var newDirectory = new Directory(parentDirectory, directory.Name);

            foreach (var dir in directory.Directories)
            {
                newDirectory.Add(d => CreateMetaDirectory(d, dir));
            }

            foreach (var file in directory.Files)
            {
                newDirectory.Add(d => FilePropertiesFile.ForFile(d, file));
            }
            
            newDirectory.Add(d => DirectoryPropertiesFile.ForDirectory(d, directory));
            
            return newDirectory;
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:18,代码来源:FileSystemToMetaFileSystemConverter.cs

示例2: Convert

        IDirectory Convert(IDirectory newParent, IDirectory toConvert)
        {            
            // determine name of new directory
            var newDirectoryName = toConvert.Name;
            foreach (var file in toConvert.Files)
            {
                var name = GetDirectoryNameDynamic(file);
                if (name != null)
                {
                    newDirectoryName = name;
                    break;
                }
            }
           
            var newDirectory = new Directory(newParent, newDirectoryName);            

            foreach (var childDirectory in toConvert.Directories)
            {
                var newChildDirectory = (IDirectory) ConvertDynamic(newDirectory, childDirectory);
                if (newChildDirectory != null)
                {
                    newDirectory.Add(_ => newChildDirectory);
                }

                
            }

            foreach (var file in toConvert.Files)
            {
                var newFile = (IFile) ConvertDynamic(newDirectory, file);
                if (newFile != null)
                {
                    newDirectory.Add(_ => newFile);
                }
            }


            return newDirectory;
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:39,代码来源:MetaFileSystemToFileSystemConverter.cs

示例3: Convert

        public override IDirectory Convert(IDirectory newParent, IDirectory toConvert)
        {
            var newDirectory = new Directory(newParent, toConvert.Name);

            foreach (var subDirectory in toConvert.Directories)
            {
                var newSubDirectory = (IDirectory) ConvertDynamic(newDirectory, subDirectory);
                if (newSubDirectory != null)
                {
                    newDirectory.Add(_ => newSubDirectory);
                }
            }

            foreach (var file in toConvert.Files)
            {
                var newFile = (IFile) ConvertDynamic(newDirectory, file);
                if (newFile != null)
                {
                    newDirectory.Add(_ => newFile);
                }
            }

            return newDirectory;
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:24,代码来源:MetaFileSystemLoader.cs

示例4: Create

        public static GitBasedMultiFileSystemSnapshot Create(Repository repository, BranchName branchName, IHistoryService historyService)
        {
            var directoryCreator = new LocalItemCreator();            

            var branch = repository.GetBranch(branchName);

            string commitId;
            using (var workingRepository = new TemporaryWorkingDirectory(repository.Info.Path, branch.FriendlyName))
            {

                var snapshotDirectory = new Directory(null, s_SnapshotDirectoryName);
                foreach (var fileSystemHistory in historyService.Items)
                {
                    var fileName = fileSystemHistory.Name + s_FileNameSuffix;
                    var content = fileSystemHistory.LatestFileSystemSnapshot?.Id ?? "";
                    snapshotDirectory.Add(d => new TextFile(d, fileName, content));
                }
                
                var snapshotDirectoryPath = Path.Combine(workingRepository.Location, s_SnapshotDirectoryName);
                directoryCreator.CreateDirectoryInPlace(snapshotDirectory, snapshotDirectoryPath, true);

                if (workingRepository.HasChanges)
                {
                    try
                    {
                        commitId = workingRepository.Commit("Created multi-filesystem snapshot");
                        workingRepository.Push();
                    }
                    catch (EmptyCommitException)
                    {
                        // no changes after all (HasChanges does not seem to be a 100% accurate)
                        commitId = repository.GetBranch(branchName).Tip.Sha;
                    }

                }
                else
                {
                    commitId = repository.GetBranch(branchName).Tip.Sha;
                }
            }

            var commit = repository.Lookup<Commit>(commitId);
            return IsSnapshot(commit) ? new GitBasedMultiFileSystemSnapshot(commit, historyService) : null;
        }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:44,代码来源:GitBasedMultiFileSystemSnapshot.cs

示例5: UpdateCurrentState

 void UpdateCurrentState()
 {
     var dir = new Directory(null, "root");
     foreach (var file in m_Files.Values)
     {
         dir.Add(d => file.WithParent(d));
     }
     CurrentState = dir;
 }
开发者ID:ap0llo,项目名称:SyncTool,代码行数:9,代码来源:HistoryBuilder.cs


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