We got a homework in college, to make a Local web-site using MVC and VB, that will read from a Json file (that is places in the App_Data folder) some seed data and populate the database.
The problem is, I’m not sure how to make Json read from the file in App_data, without assigning a full address to it.
What happens, pretty much, is I give it an address:
File.ReadFile("~/App_Data/emails.json") 'Also tried "App_Data/emails.json"
After that, I pass this path (as filename) to a StreamReader:
Using fileRead As New IO.StreamReader(filename)
Json read stuff
And instead of reading this address as the address of the Project (“C:\Users\BlueLight\Desktop\Codes\VBA\NMCAss2\App_Data\emails.json”) it throws an Exception, that it
“could not find a part of the path ‘C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\App_Data\emails.json’.” So, it searches in a different place.
Can I redirect this path to my App_Data, without using the full path? Or, maybe there is a problem somewhere in my logic?
Thanks in advance.
Update: I tried reversing “/” with “\” like “App_Data\filename.json” and “‘~\App_Data\filename.json” it still didn’t work.
Apparently, the best way to fix it is using
Works perfectly.