Beginner .Net Course: How to Add Text to a File

How to add text to a file in a single line?

File.AppendAllText(@"c:\path\file.txt", "text content" + Environment.NewLine);

And there you go! No need to open a StreamWriter in C# and all the rest, this works in a single line.

See Microsoft doc: https://docs.microsoft.com/fr-fr/dotnet/api/system.io.file.appendalltext

Aucun commentaire pour le moment.

Une erreur s'est produite. Cette application peut ne plus répondre jusqu'à ce qu'elle soit rechargée.Veuillez contacter l'auteur. Reload 🗙