C#中怎么对文本文件进行添加文本操作

本篇文章给大家分享的是有关C#中怎么对文本文件进行添加文本操作,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

using System;   using System.IO;   class Test     //C#操作文本文件之添加文本操作{   public static void Main()    {   // Create an instance of StreamWriter to write text to a file.   // The using statement also closes the StreamWriter.   using (StreamWriter sw = new StreamWriter("TestFile.txt"))    {   // Add some text to the file.   sw.Write("This is the ");   sw.WriteLine("header for the file.");   sw.WriteLine("-------------------");   // Arbitrary objects can also be written to the file.   sw.Write("The date is: ");   sw.WriteLine(DateTime.Now);   }   //C#操作文本文件之添加文本操作}   }

以上就是C#中怎么对文本文件进行添加文本操作,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。