browse files and sync

Hi,
can anyone please advise how to browse and select the files or documents from storage (either internal or external SD) in xamarin forms. my requirement is to collect the needed files list and to store in app's personal folder, then at the time of synchronization i need to upload it to server. This should work in android, ios & win phone.

string folderName = "Documents";
var docsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var folderPath = System.IO.Path.Combine(docsPath, folderName);

Answers

  • leninmathileninmathi USMember ✭✭

    any sample code snippet???

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    I think you have to use dependencyservice and platform specific code to interact with files

  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    @AlessandroCaliaro No, you can use the PCLStorage Component. https://github.com/dsplaisted/PCLStorage

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Never used but can be an answer

  • ThomasBurkhartThomasBurkhart DEMember ✭✭✭✭

    Works perfectly for me

  • leninmathileninmathi USMember ✭✭

    Hi,

    i'm consuming the Intent using dependency service to get the files to upload (user can choose) in xamarin forms. it works fine, but i need to get the filename with filepath which was chosed by the user. any help???

    /// Xamarin forms
    void addNew_toolbar_Clicked(object sender, EventArgs e)
    {
    /// Intent FileManager
    var operationsList = DependencyService.Get();
    operationsList.GetFromStorage();
    }

    /// Service
    public void GetFromStorage()
    {
    Intent intent = new Intent(Intent.ActionGetContent);
    intent.AddCategory(Intent.CategoryDefault);
    intent.AddCategory(Intent.CategoryOpenable);
    intent.SetType("/");

                try
                {
                    Forms.Context.StartActivity(Intent.CreateChooser(intent, "Select a File to Upload"));
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Xamarin.Forms.Forms.Context, "No application available to View", ToastLength.Short).Show();
                }
        }
    
  • leninmathileninmathi USMember ✭✭

    any help on this??? i need to get the file path which was picked by the user, and to save it another location.

  • leninmathileninmathi USMember ✭✭

    can anyone please help me on the android intent option equivalent in windows phone??? if so provide me the link's.

Sign In or Register to comment.