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


C# FileSystem.WriteStringToFile方法代码示例

本文整理汇总了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);
            });
        }
开发者ID:storyteller,项目名称:Storyteller,代码行数:32,代码来源:Exporter.cs

示例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));
        }
开发者ID:bobpace,项目名称:fubucore,代码行数:8,代码来源:FilesSystem_load_from_file.cs

示例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());
        }
开发者ID:awelburn,项目名称:FubuCsProjFile,代码行数:11,代码来源:RakeFileTransformTester.cs

示例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);
        }
开发者ID:bobpace,项目名称:fubucore,代码行数:11,代码来源:FilesSystem_load_from_file.cs

示例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")
                );
        }
开发者ID:bobpace,项目名称:fubucore,代码行数:25,代码来源:FileSystemTester.cs

示例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);
        }
开发者ID:ventaur,项目名称:ripple,代码行数:15,代码来源:RippleFileSystemTester.cs

示例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();
        }
开发者ID:cprieto,项目名称:fubumvc,代码行数:16,代码来源:ZipFileServiceTester.cs

示例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" });
        }
开发者ID:modulexcite,项目名称:ripple,代码行数:18,代码来源:IntegratedInitCommandTester.cs

示例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");
        }
开发者ID:bobpace,项目名称:fubucore,代码行数:9,代码来源:FileSystemTester.cs

示例11: WriteToFileSmokeTest

 public void WriteToFileSmokeTest()
 {
     string sometext = "as;lkdjf;lsakdjf;lksaddjf;lkjdsf;lkjads;lfkhsad;lkjfjh";
     var system = new FileSystem();
     system.WriteStringToFile(sometext, "sometext.txt");
 }
开发者ID:adymitruk,项目名称:storyteller,代码行数:6,代码来源:FileSystemTester.cs

示例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"));
        }
开发者ID:adymitruk,项目名称:storyteller,代码行数:9,代码来源:FileSystemTester.cs

示例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");
        }
开发者ID:JasperFx,项目名称:baseline,代码行数:9,代码来源:FileSystemTester.cs

示例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;
            }
开发者ID:modulexcite,项目名称:ripple,代码行数:24,代码来源:SolutionScenario.cs

示例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);
            }
        }
开发者ID:ventaur,项目名称:FubuWorld,代码行数:15,代码来源:TopicRequest.cs


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