本文整理汇总了C#中System.IO.FileSystem.WriteStringToFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.WriteStringToFile方法的具体用法?C# FileSystem.WriteStringToFile怎么用?C# FileSystem.WriteStringToFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileSystem
的用法示例。
在下文中一共展示了FileSystem.WriteStringToFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: should_thrown_when_file_is_not_xml
public void should_thrown_when_file_is_not_xml()
{
var fileSystem = new FileSystem();
var fileName = Path.GetTempFileName();
fileSystem.WriteStringToFile(fileName, "not xml!");
typeof(ApplicationException).ShouldBeThrownBy(() => fileSystem.LoadFromFile<SerializeMe>(fileName));
}
示例3: find_file_with_rakefile
public void find_file_with_rakefile()
{
var fileSystem = new FileSystem();
fileSystem.DeleteDirectory("oak");
fileSystem.CreateDirectory("oak");
fileSystem.WriteStringToFile("oak".AppendPath("rakefile"), "something");
RakeFileTransform.FindFile("oak").ToLower()
.ShouldEqual("oak".AppendPath("rakefile").ToFullPath().ToLower());
}
示例4: should_deserialize_xml
public void should_deserialize_xml()
{
var fileSystem = new FileSystem();
var fileName = Path.GetTempFileName();
fileSystem.WriteStringToFile(fileName, SerializeMe.SerializedXml);
var result = fileSystem.LoadFromFile<SerializeMe>(fileName);
result.Name.ShouldEqual("Serialized Name");
result.Index.ShouldEqual(42);
}
示例5: copy_directory
public void copy_directory()
{
var system = new FileSystem();
system.ResetDirectory("dagobah");
system.WriteStringToFile("dagobah".AppendPath("f1", "a.txt"), "something");
system.WriteStringToFile("dagobah".AppendPath("f2", "a.txt"), "something");
system.WriteStringToFile("dagobah".AppendPath("f3", "a.txt"), "something");
system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "a.txt"), "something");
system.WriteStringToFile("dagobah".AppendPath("f1", "f1a", "f1b", "a.txt"), "something");
system.WriteStringToFile("dagobah".AppendPath("a.txt"), "something");
system.DeleteDirectory("rhenvar");
system.Copy("dagobah", "rhenvar");
system.FindFiles("rhenvar", FileSet.Everything()).Select(x => x.PathRelativeTo("rhenvar")).OrderBy(x => x)
.ShouldHaveTheSameElementsAs(
"a.txt",
FileSystem.Combine("f1", "a.txt"),
FileSystem.Combine("f1", "f1a", "a.txt"),
FileSystem.Combine("f1", "f1a", "f1b", "a.txt"),
FileSystem.Combine("f2", "a.txt"),
FileSystem.Combine("f3", "a.txt")
);
}
示例6: use_web_config_if_it_exists
public void use_web_config_if_it_exists()
{
var fileSystem = new FileSystem();
fileSystem.DeleteDirectory("Service");
fileSystem.CreateDirectory("Service");
fileSystem.CreateDirectory("Service", "bin");
fileSystem.WriteStringToFile("Service".AppendPath("Web.config"), "foo");
var expression = new RemoteDomainExpression();
expression.ServiceDirectory = "Service";
Path.GetFileName(expression.Setup.ConfigurationFile).ShouldEqual("web.config");
}
开发者ID:DarthFubuMVC,项目名称:bottles,代码行数:14,代码来源:RemoteDomain_determination_of_the_app_config_file_Tester.cs
示例7: SetUp
public void SetUp()
{
theCodeDir = ".".AppendPath("code");
theSolutionDir = theCodeDir.AppendPath("ripple");
theCurrentDir = theSolutionDir.AppendPath("src", "project1");
var fileSystem = new FileSystem();
fileSystem.CreateDirectory(theCodeDir);
fileSystem.CreateDirectory(theSolutionDir);
fileSystem.CreateDirectory(theCurrentDir);
fileSystem.WriteStringToFile(Path.Combine(theSolutionDir, SolutionFiles.ConfigFile), "");
RippleFileSystem.StubCurrentDirectory(theCurrentDir);
}
示例8: create_test_zip_to_a_nonexistent_path
public void create_test_zip_to_a_nonexistent_path()
{
var fileSystem = new FileSystem();
fileSystem.DeleteDirectory(".\\nonexist");
fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeFalse();
fileSystem.WriteStringToFile(".\\bob.txt","hi");
var service = new ZipFileService(fileSystem);
service.CreateZipFile(".\\nonexist\\silly.zip", f=>
{
f.AddFile(".\\bob.txt","");
});
fileSystem.FileExists(".\\nonexist\\silly.zip").ShouldBeTrue();
}
示例9: SetUp
public void SetUp()
{
theFileSystem = new FileSystem();
theSolutionDir = Guid.NewGuid().ToString().ToFullPath();
theFileSystem.CreateDirectory(theSolutionDir);
theFileSystem.CreateDirectory(theSolutionDir, "src");
theFileSystem.WriteStringToFile(Path.Combine(theSolutionDir, "src", "Solution.sln"), "");
createProject("ProjectA");
createProject("ProjectB");
createProject("ProjectC");
RippleFileSystem.StopTraversingAt(theSolutionDir.ParentDirectory());
RippleFileSystem.StubCurrentDirectory(theSolutionDir);
new InitCommand().Execute(new InitInput { Name = "Test" });
}
示例10: copy_with_preserve
public void copy_with_preserve()
{
var system = new FileSystem();
system.WriteStringToFile("a.txt", "something");
system.WriteStringToFile("b.txt", "else");
system.Copy("a.txt", "b.txt", CopyBehavior.preserve);
system.ReadStringFromFile("b.txt").ShouldEqual("else");
}
示例11: WriteToFileSmokeTest
public void WriteToFileSmokeTest()
{
string sometext = "as;lkdjf;lsakdjf;lksaddjf;lkjdsf;lkjads;lfkhsad;lkjfjh";
var system = new FileSystem();
system.WriteStringToFile(sometext, "sometext.txt");
}
示例12: WriteAndReadText
public void WriteAndReadText()
{
string theString = Guid.NewGuid().ToString();
var system = new FileSystem();
system.WriteStringToFile(theString, "test.txt");
Assert.AreEqual(theString, system.ReadStringFromFile("test.txt"));
}
示例13: copy_with_overwrite
public void copy_with_overwrite()
{
var system = new FileSystem();
system.WriteStringToFile("a.txt", "something");
system.WriteStringToFile("b.txt", "else");
system.Copy("a.txt", "b.txt", CopyBehavior.overwrite);
system.ReadStringFromFile("b.txt").ShouldBe("something");
}
示例14: Assembly
public PublishesExpression Assembly(string assembly, string name = null)
{
// TODO -- Need to create the binary on the fly
if (name.IsEmpty())
{
name = assembly.Replace(".dll", "");
}
// Fake the binaries
var binaryPath = "src{0}{1}{0}bin{0}Debug".ToFormat(Path.DirectorySeparatorChar, name);
var binaryFile = "{0}{1}{2}".ToFormat(binaryPath, Path.DirectorySeparatorChar, assembly);
// ..\..\src\Bottles\bin\Debug\Bottles.dll
var relativePath = "..{0}..{0}{1}".ToFormat(Path.DirectorySeparatorChar, binaryFile);
_spec.AddPublishedAssembly(relativePath);
var files = new FileSystem();
files.CreateDirectory(_solution.Directory.AppendPath(binaryPath));
files.WriteStringToFile(_solution.Directory.AppendPath(binaryFile), "");
return this;
}
示例15: WriteFiles
public void WriteFiles()
{
var fileSystem = new FileSystem();
var directory = NamespacedDirectory();
writeSparkFile(directory, fileSystem);
var classFile = directory.AppendPath(TopicName + ".cs");
if (!fileSystem.FileExists(classFile))
{
Console.WriteLine("Writing " + classFile);
var content = TopicClassTemplate.ToFormat(typeof (Topic).Namespace, FullNamespace, TopicName, Title);
fileSystem.WriteStringToFile(classFile, content);
}
}