C#使用StreamWriter寫入文件的方法
更新時間:2015年05月19日 14:46:18 作者:lele
這篇文章主要介紹了C#使用StreamWriter寫入文件的方法,涉及C#中StreamWriter類操作文件的相關技巧,需要的朋友可以參考下
本文實例講述了C#使用StreamWriter寫入文件的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace W { class Program { static void Main(string[] args) { using (StreamWriter sw = new StreamWriter (@"c:\1.txt",true,Encoding.UTF8)) { for (int i = 0; i < 100; i++) { sw.WriteLine(i); } } Console.WriteLine("寫入完畢!"); } } }
希望本文所述對大家的C#程序設計有所幫助。
相關文章
C# httpwebrequest訪問HTTPS錯誤處理方法
下面小編就為大家?guī)硪黄狢# httpwebrequest訪問HTTPS錯誤處理方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01淺談Async和Await如何簡化異步編程(幾個實例讓你徹底明白)
本篇文章主要介紹了淺談Async和Await如何簡化異步編程,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-12-12gridview的buttonfield獲取該行的索引值(實例講解)
本篇文章主要介紹了gridview的buttonfield獲取該行的索引值(實例講解)需要的朋友可以過來參考下,希望對大家有所幫助2014-01-01