{"id":114,"date":"2012-07-24T10:02:33","date_gmt":"2012-07-24T10:02:33","guid":{"rendered":"http:\/\/newsite.foxware.co.uk\/?p=114"},"modified":"2012-07-24T10:34:27","modified_gmt":"2012-07-24T10:34:27","slug":"write-string-to-file","status":"publish","type":"post","link":"http:\/\/foxware.co.uk\/?p=114","title":{"rendered":"Write String to File"},"content":{"rendered":"<p>This example writes the contents of a string to a text file.<\/p>\n<pre class=\"lang:c# decode:true\" title=\"String write\">\n string mydocpath = \n        \tEnvironment.GetFolderPath(Environment.SpecialFolder.MyDocuments);\n        StringBuilder sb = new StringBuilder();\n\n        foreach (string txtName in Directory.EnumerateFiles(mydocpath,\"*.txt\"))\n        {\n            using (StreamReader sr = new StreamReader(txtName))\n            {\n                sb.AppendLine(txtName.ToString());\n                sb.AppendLine(\"= = = = = =\");\n                sb.Append(sr.ReadToEnd());\n                sb.AppendLine();\n                sb.AppendLine();\n            }\n\n        }\n\n        using (StreamWriter outfile = \n        \tnew StreamWriter(mydocpath + @\"\\AllTxtFiles.txt\"))\n        {\n            outfile.Write(sb.ToString());\n        }\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This example writes the contents of a string to a text file. string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); StringBuilder sb = new StringBuilder(); foreach (string txtName in Directory.EnumerateFiles(mydocpath,&#8221;*.txt&#8221;)) { using (StreamReader sr = new StreamReader(txtName)) { sb.AppendLine(txtName.ToString()); sb.AppendLine(&#8220;= = = = = &hellip; <a href=\"http:\/\/foxware.co.uk\/?p=114\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/114"}],"collection":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=114"}],"version-history":[{"count":3,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":131,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/114\/revisions\/131"}],"wp:attachment":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}