Answers for "how to write to text file in c# program"

C#
14

asp.net c# write string to text file

using (StreamWriter writer = new StreamWriter("email.txt", true)) //// true to append data to the file
{
    writer.WriteLine("your_data"); 
}
Posted by: Guest on July-01-2020
5

write text files with C#

// Create a file to write to.
string createText = "Hello and Welcome" + Environment.NewLine;
File.WriteAllText(path, createText);

...

// Open the file to read from.
string readText = File.ReadAllText(path);
Posted by: Guest on October-23-2020
0

how to write to text file in c# program

using System.IO;
using System.Threading.Tasks;

class WriteAllLines
{
    public static async Task ExampleAsync()
    {
        string[] lines =
        {
            "First line", "Second line", "Third line" 
        };

        await File.WriteAllLinesAsync("WriteLines.txt", lines);
    }
}
Posted by: Guest on May-30-2021

Code answers related to "how to write to text file in c# program"

C# Answers by Framework

Browse Popular Code Answers by Language