Forum Xamarin.Android

Append a text file on shared network folder on a computer with Android software

I am very very new at this. Trying to append a text file on my computer on a shared folder with an Android software. My code is here:

        button.Click += delegate
        {
            using( StreamWriter sw = new StreamWriter( @"\\MEHMET-PC\Deneme\deneme1.txt" , true) )
            {
                sw.WriteLine( "merhaba" );
            }
        };

I get this error :
System.UnauthorizedAccessException: Access to the path "/\MEHMET-PC\Deneme\deneme1.txt" is denied.

Things I tryed:
- I tryed to do it on sd card. It worked, i just changed the url to a random folder in my sd card. So I think StreamWriter works.
- I tryed \192.168.5.169\Deneme\deneme1.txt and other variations like double backslash etc. Every url that works on my explorer. Got the same error.
- I can just paste this url to my explorer or any other computer in the network, the file and folder is shared.
- I gave permission to "Everyone" and "NETWORK SERVICE" with "Full Control" in both sharing and security properties of the folder

I am using Visual Studio 2015. I am debugging it on my phone HTC Desire HD A9191 with Android 2.3 API 10. My pc have Windows 10 and connected to the network via ethernet.

I am suspecting an Android software permission is missing, because it gave me the same error while trying to save the text file on sd card until I selected permission WRITE_EXTERNAL_STORAGE, but couldn't find the permision related to this issue. Any help would be appreciated.

Thanks!

Sign In or Register to comment.