Reputation: 35
I coded a small Android application using Xamarin. There is part in MainActivity class where i access a File called "ListColorRGB.txt".
string path = "C:\\ListColorRGB.txt";
StreamReader sr = new StreamReader(path);
When debugging, I get the following exception:
System.IO.FileNotFoundException: Could not find file "//C:\ListColorRGB.txt".
I don't know where the two slashes came from as I didn't specify them in the first place?
Visual Studio 13, Windows 8.1
Upvotes: 1
Views: 2432
Reputation: 11
You can also access your resources in PCL proyect using File Handling in Xamarin.Forms
Upvotes: 0
Reputation: 89092
You Android app is running inside an Android emulator on your PC (or on an actual Android device). The app does not have access to your PC's file system. It can only access files that are included with the app bundle, or are in accessible sections of the emulator/device's file system.
If you want to include a file as part of your app, you can add it to your project as an Asset.
Upvotes: 5