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

站在用戶的角度思考問題,與客戶深入溝通,找到邯鄲網(wǎng)站設(shè)計(jì)與邯鄲網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋邯鄲地區(qū)。
- using System.IO;
- //聲明控件
- protected System.Web.UI.HtmlControls.HtmlTextArea txtValue;
C#操作文本文件之讀取文本文件:
- //主程序
- FileStream fsInfo = new FileStream(
- "文件路徑(在項(xiàng)目內(nèi)的)", 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(
- 文件路徑(在項(xiàng)目內(nèi)的)", 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#操作文本文件的基本實(shí)現(xiàn)內(nèi)容就向你介紹到這里,希望對你了解和學(xué)習(xí)C#操作文本文件有所幫助。
本文名稱:C#操作文本文件實(shí)例淺析
網(wǎng)站鏈接:http://fisionsoft.com.cn/article/dhhjssc.html


咨詢
建站咨詢
