新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#操作文本文件實例淺析
C#操作文本文件是如何實現(xiàn)的呢?讓我們開始講述吧:

站在用戶的角度思考問題,與客戶深入溝通,找到邯鄲網(wǎng)站設計與邯鄲網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術結合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網(wǎng)站制作、成都做網(wǎng)站、外貿營銷網(wǎng)站建設、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名注冊、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務覆蓋邯鄲地區(qū)。
- using System.IO;
- //聲明控件
- protected System.Web.UI.HtmlControls.HtmlTextArea txtValue;
C#操作文本文件之讀取文本文件:
- //主程序
- FileStream fsInfo = new FileStream(
- "文件路徑(在項目內的)", FileMode.Open, FileAccess.Read );
- StreamReader srInfo = new StreamReader(
- fsInfo, System.Text. Encoding.GetEncoding( "GB2312" ) );
- srInfo.BaseStream.Seek( 0, SeekOrigin.Begin );
- txtValue.Value = " ";
- string strLine = srInfo.ReadInfo();
- while( strLine != null )
- {
- txtValue.Value += strLine + "\n";
- strLine = srInfo.ReadLine();
- }
- srInfo.Close();
C#操作文本文件之寫入文本文件:
- //主程序
- FileStream fsInfo = new FileStream(
- 文件路徑(在項目內的)", FileMode.OpenOrCreate, FileAccess.Write );
- StreamWriter swInfo = new StreamWriter( fsInfo );
- swInfo.Flush();
- swInfo.BaseStream.Seek( 0, SeekOrigin.Begin );
- swInfo.Write( txtValue.Value );
- swInfo.Flush();
- swInfo.Close();
C#操作文本文件的基本實現(xiàn)內容就向你介紹到這里,希望對你了解和學習C#操作文本文件有所幫助。
當前題目:C#操作文本文件實例淺析
當前地址:http://m.5511xx.com/article/dhhjssc.html


咨詢
建站咨詢
