當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。