Reputation: 45
I have a Xamarin.Forms
GetFiles.IOS project that has a "Resources" directory that's part of the project. I have placed 25 files into the Resources Directory. I now want to be able to go to the resource directory and get all the file names. I created some code to read the files in the directory but I'm getting a DirectoryNotFoundException
. Here's the code I'm using.
String dir = Directory.GetCurrentDirectory();
var filePath = Path.Combine(dir,"Resources");
String[] files = Directory.GetFiles(filePath);
I just can't seem to get the path correct! Thank you for helping me.
Upvotes: 1
Views: 1988
Reputation: 39082
There are two things necessary to have the files be copied into the app folder:
Content
with Copy to Output Directory Copy Always
in the Properties
window.Resources
.Number 2. is because Resources
is a special reserved directory name and even if you put some content files in it, it is never copied in the app bundle's folder. You can check for yourself, if you put the files in a folder Test
, your code will work as intended.
Upvotes: 2