C
C#2y ago
Down

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
8 Replies
Down
DownOP2y ago
This is my File tree and im trying to access MOCK_DATA.json from SearchService.cs
stayclaxxy
stayclaxxy2y ago
Try taking the ../ off
Down
DownOP2y ago
it gives me same error
stayclaxxy
stayclaxxy2y ago
make sure the file exists wherever the app is compiling to
Down
DownOP2y ago
yes checked it and it is
stayclaxxy
stayclaxxy2y ago
and it's in the same exact folder as the executable/dll? if so File.ReadAllText("MOCK_DATA.json"); should work fine
Down
DownOP2y ago
yes it is i dont know whats wrong too looks fine
stayclaxxy
stayclaxxy2y ago
maybe try debugging a bit, outputting the current directory, listing directory contents through code, seeing if it can see the file, etc
Want results from more Discord servers?
Add your server