Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Cant Access shared folder

Hi,
Iam new to xamarin. I want to read the files from shared folder.
From - access from android mobile
To - PC (contains shared folder. ).
Both this mobile and PC are in same wifi network.
I am developing in c#. Can anybody please help me to solve this.
Thanks,
Thiyagu.

Best Answer

Answers

  • Edd77Edd77 Member ✭✭

    You can try checking that you can access using this app
    https://play.google.com/store/apps/details?id=com.ape.apps.networkbrowser&hl=en_US
    After you checked that you have effective access to the folder then you sholud be able to do:

     string path = @"\\Desktop-xxxx\SahredFolder\SharedFile.txt";
        FileStream fs = null;
        if (File.Exists(path))
        {
            fs = File.Open(path, FileMode.Append);
        }
        else
        {
            fs = File.Create(path);
        }
    

    Please notice that both the computer and the android device have to be connected to the same network
    Im not sure if it will work on a emulator.

  • Edd77Edd77 Member ✭✭

    By the way instead of "\Desktop-xxxx\SahredFolder\SharedFile.txt" you can use ip address @\192.168.x.xx\SahredFolder\SharedFile.txt;

  • thiyagujthiyaguj Member ✭✭

    Hi Ed77,
    Thanks for the reply. I followed the steps as per your suggesstion.
    1) verified with network browser and i can able to access the network files successfully.
    2) Tried with the code you gave. Error prompts me as "Access to this folder is denied"

    Please help me resolve this.

  • thiyagujthiyaguj Member ✭✭

    Ed77
    Iam connecting my mobile device and checking. Not in emulator. And also both the laptop and the mobile device are connected in same network.

  • ColeXColeX Member, Xamarin Team Xamurai

    Do you enable file read/write permission in manifest ?

  • thiyagujthiyaguj Member ✭✭
    Coles,
    Thanks for the reply. Can you please tell me how to enable read and write permission in manifest.
Sign In or Register to comment.