problem with reading file in xamarin forms
i have this code
var data = File.ReadAllText("../MOCK_DATA.json");
and it has problems reading this file i get this error![](https://utfs.io/f/30a9fad9-c765-49a1-9d1e-522aa6108a7e-1nq2cb.png)
8 Replies
This is my File tree and im trying to access
MOCK_DATA.json
from SearchService.cs
![](https://utfs.io/f/15d83875-3bfd-4777-875f-da41837cd50d-1nq2cb.png)
Try taking the
../
offit gives me same error
![](https://utfs.io/f/d0a69e2d-96c2-4bca-9a6d-bbc0faf132c2-1nq2cb.png)
make sure the file exists wherever the app is compiling to
yes checked it and it is
and it's in the same exact folder as the executable/dll?
if so
File.ReadAllText("MOCK_DATA.json");
should work fineyes it is i dont know whats wrong too
looks fine
maybe try debugging a bit, outputting the current directory, listing directory contents through code, seeing if it can see the file, etc