本文整理匯總了C#中System.IO.FileSystem.CopyToDirectory方法的典型用法代碼示例。如果您正苦於以下問題:C# FileSystem.CopyToDirectory方法的具體用法?C# FileSystem.CopyToDirectory怎麽用?C# FileSystem.CopyToDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.FileSystem
的用法示例。
在下文中一共展示了FileSystem.CopyToDirectory方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ExportTo
public void ExportTo(string directory, Topic root, Func<Topic, string> pathing)
{
var fileSystem = new FileSystem();
string sourceContent = _settings.Root.AppendPath("content");
if (fileSystem.DirectoryExists(sourceContent))
{
fileSystem.CopyToDirectory(sourceContent, directory.AppendPath("content"));
}
root.AllTopicsInOrder().Each(topic =>
{
var path = pathing(topic);
var parentDirectory = path.ParentUrl();
if (parentDirectory.IsNotEmpty())
{
fileSystem.CreateDirectory(directory.AppendPath(parentDirectory));
}
var text = _generator.Generate(topic);
// Hoakum
topic.Substitutions.Each((key, value) =>
{
text = text.Replace(key, value);
});
fileSystem.WriteStringToFile(directory.AppendPath(path), text);
});
}
示例2: ExplodeTo
public IPackage ExplodeTo(string directory)
{
var explodedDirectory = ExplodedDirectory(directory);
RippleLog.Info("Exploding to " + explodedDirectory);
var fileSystem = new FileSystem();
fileSystem.CreateDirectory(explodedDirectory);
fileSystem.ForceClean(explodedDirectory);
var package = new ZipPackage(_path);
package.GetFiles().Each(file =>
{
var target = explodedDirectory.AppendPath(file.Path);
fileSystem.CreateDirectory(target.ParentDirectory());
using (var stream = new FileStream(target, FileMode.Create, FileAccess.Write))
{
file.GetStream().CopyTo(stream);
}
});
fileSystem.CopyToDirectory(_path, explodedDirectory);
fileSystem.DeleteFile(_path);
var newFile = Path.Combine(explodedDirectory, Path.GetFileName(_path));
return new ZipPackage(newFile);
}