How do I create a text file and write the contents of a string to it? I plan to reference to the text file later. It could be on the se开发者_Go百科rver (root folder) or anywhere where I can reference it. Below is the string contents
foreach (string s in strValuesToSearch)
{
if (result.Contains(s))
result = result.Replace(s, stringToReplace);
You could use the WriteAllText method:
string result = "foo bar";
File.WriteAllText(@"c:\foo.txt", result);
As long as you have proper permission to write on the server you can take advantage of the methods of the System.IO.File
class
System.IO.File.WriteAllText
精彩评论