C#操作文本文件之添加文本操作淺析
作者:花花藏子
C#操作文本文件之添加文本操作是如何實(shí)現(xiàn)呢?C#操作文本文件之添加文本操作具體的實(shí)現(xiàn)是如何的呢?那么本文就向你介紹相關(guān)的內(nèi)容。
C#操作文本文件之添加文本操作是如何實(shí)現(xiàn)的呢?讓我們來(lái)看看具體的實(shí)例方式:
- 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#操作文本文件之添加文本操作的基本情況就向你介紹到這里,希望對(duì)你了解和學(xué)習(xí)C#操作文本文件有所幫助。
【編輯推薦】
責(zé)任編輯:仲衡
來(lái)源:
CSDN博客