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

How to open csv files in xamarin.ios multiplatform application?

$
0
0

hello all ,
I am working on xamarin.forms app, the aim of my app is to open and read csv file, in xamarin.android build works fine but when I try to run the same app in xamarin.ios and try to open the files folder and look for csv files I see that csv files are greyed out, so I am not able to select and open the csv file whereas I am able to open the .xlslx file for which I did not code in program for this extension ,can anyone please suggest me If i have to make any changes in xamarin.ios app so that I can open the csv files?here is the related code ,do i need to give any permissions for the ios app ?

          public async void OnBrowse(object o, EventArgs args)
    {
        try
        {
            //  var file_path =  
            this.file = await CrossFilePicker.Current.PickFile().ConfigureAwait(true); /*CrossFilePicker.Current.PickFile();//*/
            if (this.file == null)
            {
                // return;
            }
            else
            {
                string extensionType = this.file.FileName.Substring(
                    this.file.FileName.LastIndexOf(".", StringComparison.Ordinal) + 1,
                    this.file.FileName.Length - this.file.FileName.LastIndexOf(".", StringComparison.Ordinal) - 1).ToLower();

                fileName = this.file.FileName;

                if (extensionType.Equals("csv"))
                {
                    csv_file.Text = (fileName);
                }
                else
                {
                    await this.DisplayAlert("Name of the file:" + file.FileName, "File info", "OK");
                }
            }
            if (SettingsPage.loggingEnabled)
            {
                LogUtilPage.Initialize("/storage/emulated/0");
            }
        }
        catch (Exception e)
        {
            await DisplayAlert("Alert", "Something went wrong", "OK");
            if (SettingsPage.loggingEnabled)
            {
                LogUtilPage.Log(e.Message);
            }
        }


    }

Viewing all articles
Browse latest Browse all 204402

Trending Articles