How to fix file .json not found

ItsRaptorman

I am trying here to consume the data from a JSON file:

DATA.json

[

{"Label"
        
        :"USA",
        "Adress":"This is the us",
        "Lat":"36.9628066",
        "Lng":"-122.0194722"
},
{ "Label"  :"USA",
         "Address":"2020",
          "Lat":"36.9628066", 
          "Lng":"-122.0194722" }

]

Then applying it in my Mainclass:

using System.Collections.Generic;
using Xamarin.Forms.Maps;
using Xamarin.Forms;
using System.IO;
using Newtonsoft.Json;
using System;


namespace Orbage
{
    

class MapPage : ContentPage
    {
        public MapPage()
        {
            CustomMap customMap = new CustomMap
            {
                MapType = MapType.Street

            };
            // ...
            Content = customMap;

            var json = File.ReadAllText("File.json");
            var places = JsonConvert.DeserializeObject<List<File>>(json);
            foreach (var place in places)
            {
                CustomPin pin = new CustomPin
                {
                    Type = PinType.Place,
                    Position = new Position(Double.Parse(place.Lat), Double.Parse(place.Lng)),
                    Label = place.Label,
                    Address = place.Address,
                    Name = "Xamarin",

                    Url = "http://xamarin.com/about/"
                };



                customMap.CustomPins = new List<CustomPin> { pin };

                customMap.Pins.Add(pin);
                customMap.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(37.79752, -122.40183), Distance.FromMiles(1.0)));
            }
        }
    }


}

But when I put the file in there it says that it doesn't exist.

Error:

FilenotfoundException

Whats the fix for this.
I tried:

  • Changing the location of the file.
  • Its name = Instead of E:/-/- I even wrote file.json but I still get the same error.
Davmi José Valdez Ogando

Looks like the problem is how you are trying to access your json. I'm not sure(because it doesn't say) as to where are you storing it, but here the docs explain a smooth explanation as to how access stored files in a mobile phone using Xamarin Forms

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to fix file .json not found when it is there

How to fix creating a new object in JSON file?

How to fix failed to locate file json in Swift

webpack error: File to import not found or unreadable: bourbon , how to fix?

TSIFY module not found html file. how do fix?

How to fix the error `found no layout file for "HTML" for "page"` in Hugo CMS?

How to fix 'sh: 1: path/to/file not found ' python random generator

How to fix 'character map file `UTF-8' not found'

How to fix 'grub error file not found' when installing 12.04?

How to fix Resource not found exception?

How to fix HttpErrorResponse 404 Not found

How to fix No suitable constructor found

How to Fix class not found in Laravel

How to fix: Delete duplicates in a JSON file and write to a new one

How to efficiently fix JSON file converted from pandas dataframe

How to fix PyCurl command not uploading JSON file to server

How do I fix json file reading code NodeJS Electron

How to parse a Really Big Incorrectly Saved JSON file to fix it

JSON file not found

How to fix: mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf?

How to fix Realm warning Invalid Source (file not found primitive_list_notifier.cpp)

How to fix "no executable found matching command "dotnet-ef"" with the new csproj file

How to fix boot into initramfs prompt and "mount: can't read '/etc/fstab': No such file or directory" and "No init found"?

How do I fix this source not found error? Reading text file with buffered reader - Java

How to I fix this? f1026 file not found 'crt.dcu'

How to fix "More than one file was found with OS independent path 'META-INF/DEPENDENCIES' error in Android

How fix error Xcode. Lexical preprocessor issue Cordova/CDVJpegHeaderWriter.h' file not found

The video tag is not working, it says file not found. How do I fix this?

How to fix a not creating file