C#操作文本文件之添加文本操作淺析
作者:花花藏子
C#操作文本文件之添加文本操作是如何實現呢?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#操作文本文件之添加文本操作的基本情況就向你介紹到這里,希望對你了解和學習C#操作文本文件有所幫助。
【編輯推薦】
責任編輯:仲衡
來源:
CSDN博客