コード例 #1
0
 public void          XML_Carga(string raizW, string raizL, string[] arqs)
 {
     Mensaje_Curto("Carregando arquivos da Web...");
     foreach (string arq in arqs)
     {
         HttpWebRequest   llamadas = (HttpWebRequest)WebRequest.Create(raizW + arq);
         HttpWebResponse  resposta = (HttpWebResponse)llamadas.GetResponse();
         System.IO.Stream txt      = resposta.GetResponseStream();
         StreamWriter     doc      = new StreamWriter(raizL + arq);
         byte[]           buf      = new byte[8192];
         string           lin      = null;
         int con = 1;
         while (con > 0)
         {
             con = txt.Read(buf, 0, buf.Length);
             if (con != 0)
             {
                 lin = System.Text.Encoding.UTF8.GetString(buf, 0, con);
                 doc.WriteLine(lin);
             }
         }
         doc.Close();
         doc.Dispose();
     }
     Mensaje_Curto("Arquivos XML carregados no telefone.");
 }
コード例 #2
0
        public static string ReadJsonFromInternalStorage(System.IO.Stream fileStream)
        {
            const long bufferLength = 1024 * 1024 * 20;

            byte[] jsonBytes = new byte[bufferLength];

            fileStream.Read(jsonBytes, 0, jsonBytes.Length);

            var json = GetString(jsonBytes);

            return(json);
        }
コード例 #3
0
 public static byte[] ReadFully(System.IO.Stream input)
 {
     byte[] buffer = new byte[16 * 1024];
     using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
     {
         int read;
         while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
         {
             ms.Write(buffer, 0, read);
         }
         return(ms.ToArray());
     }
 }