Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to read a txt file with Android.Net.Uri uri.ToString() file path

$
0
0

Hello,
I can't open a text file using StreamReader and file piker byte[] fullpath location, i think the proble is the version of client android version api18 - 19 .

Now i need open text file trying another library to pick and read, and i arrived until this line:

Android.Net.Uri uri = data.Data;
filePathEstab = uri.ToString(); // /content:/com.android.externalstorage.documents/document/2DB1-D39F%3ADownload%2FMyText.txt"

StreamReader/ OR Another reader estab = new StreamReader(filePathEstab) // broke here in samsung devices, before and now with this version
while (!estab.EndOfStream)
{

                    sql.Write(() =>
                    {
                        try
                        {
                            string l = estab.ReadLine();
                            string codigoestruturado = l.Split(';')[0];
                            int codigo = Convert.ToInt32(l.Split(';')[1]);
                            string nome = l.Split(';')[2];
                            int estabelecimento = Convert.ToInt32(l.Split(';')[3]);
                            sql.Add(new DataBase.Local { LocCodEstr = codigoestruturado, LocCodigo = codigo, LocNome = nome, LocEstab = sql.All<DataBase.Estabelecimento>().Where((a) => a.EstabCod == estabelecimento).FirstOrDefault() });
                        }
                        catch
                        {
                             Log Error!
                        }
                    });

I need help to solve this problem, i dont know if exists another option to read file using Android.Net.Uri or other functionalit of Android.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>