Delpin Susai Raj Friday 20 November 2020

Xamarin.Forms - File Browser

 In this blog post, you will learn how to pick files from your device, Drive, iCloud in Xamarin.Forms.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

 Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

 Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform. 

Nuget

Install following Nuget from Nuget Manager In your visual studio.

Name.      : Xamarin.Plugin.FilePicker

Version    : 2.1.41

Url           : https://www.nuget.org/packages/Xamarin.Plugin.FilePicker/

Xamarin.Essentials

Xamarin.Essentials also supports File Picker but it's in Preview. Once the FilePicker moved to stable you can update Xamarin.Pulgin.FilePicker to Xamarin.Essentials

https://docs.microsoft.com/en-us/xamarin/essentials/file-picker

Setup UI

Now, I created simple UI for file browser.

MainPage.xaml

File Browser

Below code for file picker, Here will get two values FileName and FilePath.

File Types

Note, you can define the file types for platform specific.

Reference for other file types.

https://stackoverflow.com/questions/41797644/xamarin-ios-filtering-out-the-filetype-show-on-document-picker

MainPage.Xaml.cs

Debug your App



Once select the file you will get the FileName and FilePath.

I hope you have understood you will learn how to browse file in your device and drive in Xamarin.Forms..

Thanks for reading. Please share your comments and feedback. Happy Coding :)

12 comments:

  1. would be nice to read about Folder Picker

    ReplyDelete
  2. thanks for sharinf wonderful information. guys you can find some more information related to React Native vs Xamarin

    ReplyDelete
  3. Publish Research Paper: Authors should submit the manuscript/paper that has been attentively proof-read and brilliance. Authors are mandatory to refer to the UIJRT manuscript/paper template format. This will assure fast processing and publication. Through E-mail acceptance or rejection, the notification will be sent to all authors. Fast Paper Publication

    ReplyDelete
  4. Thanks for sharing this informative content, Great work.
    To crack Scrum master interview: Scrum master interview questions

    ReplyDelete
  5. Nice blog! I really loved reading through this Blog... Thanks for sharing such a very interesting post with us and keep blogging.
    Visit our website-
    web and app development company
    hire xamarin developer
    hire ABP.io developer
    hire android developer

    ReplyDelete
  6. how to send attached file to web api??

    ReplyDelete
  7. Thanks for sharing!!!
    Your blog is very nice and we hope you are providing more information in future times.
    SEO Company Pune
    SEO Pune

    ReplyDelete
  8. I appreciate your website. Its really very help full. Thanks for sharing the great information.
    Venetian Mirror
    Wine Glass
    Bathroom Mirror

    ReplyDelete
  9. Shrewd agreement advancement involves making code to develop decentralized applications (dApps) on the blockchain that give exchange straightforwardness and trustless execution. Clients benefit from protected, unalterable tasks as well as adjustable agreements that improve on business processes, dispose of brokers, and limit exchange costs. To increment client experience and security, engineers give tailor made approaches, brilliant agreement examinations, and collaboration with other DeFi conventions>> token development company

    ReplyDelete