Začátečnický kurz .Net: Jak přidat text do souboru

Jak přidat text do souboru na jeden řádek?

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

A je to! Není potřeba otevírat StreamWriter v C# a všechno ostatní, toto funguje na jeden řádek.

Viz dokumentace Microsoftu: https://docs.microsoft.com/fr-fr/dotnet/api/system.io.file.appendalltext

Join the conversation

You need an account to comment on this article. Creating one is free and takes under a minute.

  • The XMLTV file, free to download every day
  • Comment on articles and reply to other readers
  • Get an e-mail when an article you follow is updated

No comments yet.

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