Reputation: 425
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 server (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);
Upvotes: 0
Views: 335
Reputation: 82375
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
Upvotes: 0
Reputation: 1039468
You could use the WriteAllText method:
string result = "foo bar";
File.WriteAllText(@"c:\foo.txt", result);
Upvotes: 2