Below is a sample code snippet that demonstrates how to write a string to a text file in C# .
How to Write a string to a Text File in C# ?
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;
namespace AbundantcodeConsoleApp
{
internal class Program
{
private static void Main(string[] args)
{
string ACFile = @"E:\input.txt";
using (System.IO.StreamWriter writer = File.CreateText(ACFile))
{
writer.WriteLine("Welcome to Abundantcode.com");
}
Console.ReadLine();
}
}
}
Leave a Reply