av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

C#讀取文件內(nèi)容另存的實(shí)現(xiàn)

C#讀取文件內(nèi)容另存的實(shí)現(xiàn)的如何呢?讓我們看看代碼的實(shí)現(xiàn):

 
 
 
  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.Collections;
  11. using System.IO;
  12. using System.Text;
  13. /// 
  14. ///C#讀取文件內(nèi)容另存
  15. /// Summary description for ReadFile
  16. ///
  17.  
  18. public class ReadFile
  19. {
  20.  public ReadFile()
  21.  {
  22.    //  C#讀取文件內(nèi)容
  23.    // TODO: Add constructor logic here
  24.  //
  25.     }
  26.     public int[,] ReadFileToArray()
  27.     {
  28. int[,] iret = null;  //C#讀取文件內(nèi)容另存
  29.  ArrayList alNumLine = getFileContent();
  30.    string[] strLineArr = null;
  31.  if (alNumLine.Count > 0)
  32.         {
  33.     strLineArr = Convert.ToString(alNumLine[0]).Trim(',').Split(',');
  34.   iret = new int[alNumLine.Count, strLineArr.Length];
  35.     for (int i = 0; i < alNumLine.Count; i++)
  36.             {
  37.  strLineArr = Convert.ToString(alNumLine[i]).Trim(',').Split(',');
  38.  for (int j = 0; j < strLineArr.Length; j++)
  39.  {
  40.     iret[i, j] = Convert.ToInt32(strLineArr[j]);
  41.    }
  42.             }
  43.         }
  44.         return iret;
  45.     }
  46.  //C#讀取文件內(nèi)容另存
  47.     public ArrayList getFileContent()
  48.     {
  49.  ArrayList alRet = new ArrayList();
  50.  string strFilePath = HttpContext.Current.Server.MapPath("~")
  51. + "/array.txt";
  52.  if (!File.Exists(strFilePath))
  53.         {
  54.  HttpContext.Current.Response.Write("文件[" + strFilePath + "]不存在。");
  55.             return alRet;
  56.         }
  57.  //C#讀取文件內(nèi)容另存
  58.         try
  59.         {
  60.  //讀出一行文本,并臨時(shí)存放在ArrayList中
  61.     StreamReader sr = new StreamReader(strFilePath,
  62. Encoding.GetEncoding("gb2312"));
  63.   string l;
  64.    while ((l = sr.ReadLine()) != null)
  65.             {
  66.    if (!string.IsNullOrEmpty(l.Trim()))
  67.         alRet.Add(l.Trim());
  68.             }
  69.             sr.Close();
  70.         }
  71.         catch (IOException ex)
  72.         {
  73.   HttpContext.Current.Response.Write("讀文件出錯(cuò)!請檢查文件是否正確。");
  74.   HttpContext.Current.Response.Write(ex.ToString());
  75.         }
  76.         return alRet;
  77.  //C#讀取文件內(nèi)容另存
  78.     }
  79. }

C#讀取文件內(nèi)容另存的實(shí)現(xiàn)就向你介紹到這里,希望通過這樣的介紹使你能夠明白C#讀取文件內(nèi)容另存相關(guān)內(nèi)容,希望對你有所幫助。


文章題目:C#讀取文件內(nèi)容另存的實(shí)現(xiàn)
URL分享:http://uogjgqi.cn/article/ccojiic.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們在微信上24小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流