Forum Xamarin.Forms

How to get file path on Xamarin.Plugin.FilePicker?

HarshitaHarshita INMember ✭✭✭✭
edited December 2017 in Xamarin.Forms

How to get file path on Xamarin.Plugin.FilePicker? I am getting file name and byteData but how to get file path? Here is my code-

    try
            {
                FileData filedata = new FileData();
                var crossFileData = CrossFilePicker.Current;
                filedata = await crossFileData.PickFile();
                byte[] data = filedata.DataArray;
                string name = filedata.FileName;
                AtttchFileName.Text = name;
                if(AtttchFileName.Text==null)
                {
                    DoneAttachment.IsEnabled = false;
                }
                else
                {
                    DoneAttachment.IsEnabled = true;
                }
                foreach (byte b in filedata.DataArray)
                {
                    string attachment = b.ToString();
                }

            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }

How to achieve this?

Answers

  • tribaltribal USMember ✭✭✭

    Check out this post, it seems to use a FilePath

  • Mohammad_ManjurMohammad_Manjur Member ✭✭

    how to implement file picker in Xamarin forms?

  • vinukodivinukodi Member ✭✭

    @Harshita said:
    How to get file path on Xamarin.Plugin.FilePicker? I am getting file name and byteData but how to get file path? Here is my code-

      try
                {
                    FileData filedata = new FileData();
                    var crossFileData = CrossFilePicker.Current;
                    filedata = await crossFileData.PickFile();
                    byte[] data = filedata.DataArray;
                    string name = filedata.FileName;
                    AtttchFileName.Text = name;
                    if(AtttchFileName.Text==null)
                    {
                        DoneAttachment.IsEnabled = false;
                    }
                    else
                    {
                        DoneAttachment.IsEnabled = true;
                    }
                    foreach (byte b in filedata.DataArray)
                    {
                        string attachment = b.ToString();
                    }
    
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                }
    

    How to achieve this?

    You can use filedata.FilePath

Sign In or Register to comment.