Reading a simple text file

前端 未结 7 2019
甜味超标
甜味超标 2020-11-22 14:10

I am trying to read a simple text file in my sample Android Application. I am using the below written code for reading the simple text file.

InputStream inpu         


        
7条回答
  •  被撕碎了的回忆
    2020-11-22 14:37

    In Mono For Android....

    try
    {
        System.IO.Stream StrIn = this.Assets.Open("MyMessage.txt");
        string Content = string.Empty;
        using (System.IO.StreamReader StrRead = new System.IO.StreamReader(StrIn))
        {
          try
          {
                Content = StrRead.ReadToEnd();
                StrRead.Close();
          }  
          catch (Exception ex) { csFunciones.MostarMsg(this, ex.Message); }
          }
              StrIn.Close();
              StrIn = null;
    }
    catch (Exception ex) { csFunciones.MostarMsg(this, ex.Message); }
    

提交回复
热议问题