read txt file from storage device in xamarin?

Kumar Aman 1 Reputation point
2021-08-24T06:55:09.927+00:00

StreamReader reader = null;
var textFile = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, "\USERDETAIL.txt");
CodeContract.Required<Exception>(!File.Exists(Global.mDeviceRootDir + "\USERDETAIL.TXT"), "USERDETAIL file not found");

        _offlineUsers = new List<OfflineUserDetails>();

        reader = new StreamReader(Global.mDeviceRootDir + "\\USERDETAIL.txt");
        while (!reader.EndOfStream)
        {
            var data = reader.ReadLine();
            string[] strArr = data.Split(',');
            if (strArr.Length == 2)
            {
                //ListViewItem iItem = new ListViewItem(strArr[0].ToString());
                //for (int j = 1; j < strArr.Length; j++)
                //{
                //    iItem.SubItems.Add(strArr[j].ToString());
                //}
                //lvUser.Items.Add(iItem);
            }
        }
        reader.Close();
        reader = null;
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,326 questions
{count} votes