本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}