I am having a lot of trouble in working with streams using monodroid. What I am trying to do is simply download a file using a URL and saving it to my phone’s /sdcard location but am having problems. I am getting Access to the path ‘/mnt/sdcard’ is denied.
Code :-
Filestream strlocal;
var fileName = Android.OS.Environment.ExternalStorageDirectory;
string path = Convert.ToString(fileName);
strLocal = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write);
- When I debug the app and try to run it on my device, the debugging error points at this line of code.
In Visual Studio, I have made the manifest file using the dialog in properties in which I have given permission to write, i.e :-
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE
Also , i Tried another approach to write this permission in the main activity page, i.e :-
[Activity(Label = "MonoAndroidApplication2", MainLauncher = true,
Permission = "android.permission.WRITE_EXTERNAL_STORAGE")
But still getting the same error of denial. Also when I make the manifest file in visual studio, I get strange messages like:-
Message 5 Could not find schema information for the element 'uses-permission'.
Message 1 Could not find schema information for the element 'manifest'.
Message 2 Could not find schema information for the attribute 'package'.
What do these messages mean?. Please help me in this problem.
I am using the latest version of Monodroid (Bought it a week ago)
The problem is that you’re trying to open the FileStream using the folder’s path, rather than specifying a file name within that folder. For example:
This will create a file named MyFile.txt in the external storage folder.