自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

C#操作文本文件實例淺析

開發(fā) 后端
C#操作文本文件實例向你講述了C#操作文本文件的具體操作的過程,希望對你了解C#操作文本文件有所幫助。

C#操作文本文件是如何實現(xiàn)的呢?讓我們開始講述吧:

  1. using System.IO;  
  2.  
  3. //聲明控件  
  4. protected System.Web.UI.HtmlControls.HtmlTextArea txtValue; 

C#操作文本文件之讀取文本文件:

  1. //主程序  
  2. FileStream   fsInfo = new  FileStream(   
  3. "文件路徑(在項目內(nèi)的)", FileMode.Open, FileAccess.Read );  
  4. StreamReader  srInfo  =  new StreamReader(   
  5. fsInfo, System.Text. Encoding.GetEncoding( "GB2312" ) );  
  6. srInfo.BaseStream.Seek( 0, SeekOrigin.Begin );  
  7. txtValue.Value  = " ";  
  8. string strLine  = srInfo.ReadInfo();  
  9. while( strLine != null )  
  10. {  
  11. txtValue.Value  +=   strLine  + "\n";  
  12. strLine   =   srInfo.ReadLine();  
  13. }  
  14. srInfo.Close(); 

C#操作文本文件之寫入文本文件:

  1. //主程序  
  2. FileStream fsInfo  = new FileStream(  
  3.  文件路徑(在項目內(nèi)的)", FileMode.OpenOrCreate, FileAccess.Write );  
  4. StreamWriter swInfo = new StreamWriter( fsInfo );  
  5. swInfo.Flush();  
  6. swInfo.BaseStream.Seek( 0, SeekOrigin.Begin );  
  7. swInfo.Write( txtValue.Value );  
  8.  
  9. swInfo.Flush();  
  10. swInfo.Close(); 

C#操作文本文件的基本實現(xiàn)內(nèi)容就向你介紹到這里,希望對你了解和學(xué)習(xí)C#操作文本文件有所幫助。

【編輯推薦】

  1. C# 操作符基礎(chǔ)知識總結(jié)
  2. C# 操作符之is應(yīng)用淺析
  3. C# 操作符之三元操作符淺析
  4. C# 操作符之 . 運算符應(yīng)用詳解
  5. C# 操作符分類及應(yīng)用淺析
責(zé)任編輯:仲衡 來源: bianceng.cn
相關(guān)推薦

2009-08-20 10:17:27

C#操作文本文件

2009-08-20 09:15:20

C#操作文本文件

2009-08-20 09:58:06

C#操作文本文件

2009-09-02 19:13:08

C#處理文本文件

2009-09-02 19:08:03

C#實現(xiàn)讀取文本文件

2009-08-26 11:53:56

C#打印文本文件

2009-08-20 09:26:14

C#操作文本文件

2009-09-04 15:56:35

寫入文本文件

2009-08-06 18:33:45

C#處理文本文件

2010-01-11 17:05:32

VB.NET操作文本文

2009-08-31 18:38:59

C#寫文件

2009-08-12 17:59:48

C#讀取文本文

2009-08-18 13:49:21

C# 操作Excel

2009-08-12 17:42:57

C#讀文本文件

2009-08-19 11:34:06

C#操作Word

2009-08-19 11:13:49

C#操作Word

2010-02-01 14:26:50

C++讀寫文本文件

2009-08-18 16:04:12

C# 操作Excel

2009-08-19 09:42:52

C#操作Word書簽

2010-04-30 17:38:31

Unix文本
點贊
收藏

51CTO技術(shù)棧公眾號