locked
How to get file path on Xamarin.Plugin.FilePicker? RRS feed

  • Question

  • User355485 posted

    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?

    Saturday, December 16, 2017 8:30 AM

All replies

  • User236909 posted

    Check out this post, it seems to use a FilePath

    Saturday, December 16, 2017 10:46 AM
  • User370485 posted

    how to implement file picker in Xamarin forms?

    Thursday, July 5, 2018 9:34 AM
  • User391036 posted

    @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

    Thursday, February 13, 2020 6:42 AM
  • User398074 posted

    var pickResult = FilePicker.PickMultipleAsync(); foreach (var file in pickResult) { var streamPath = file.FullPath; // Do what you have to do with this path }

    Friday, February 5, 2021 6:04 AM