R
Railway12mo ago
Firi

Relative path issue

I am trying to read some Json files and parse them with one of my services. Locally it works fine. I've tried 3 different methods of determining the path and all of them have the same path issue So here is my deployment log message
Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Gladiators_Armor.json'.
Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Unbreakable_Guard.json'.

Error reading JSON file: Could not find file '/app/wwwroot/json/homecoming/boost_sets/Gladiators_Armor.json'.
here is my path creation that works locally in dev mode string jsonFilePath = Path.Combine("wwwroot", "json", "homecoming", "boost_sets", $"{enhancementName}.json"); string jsonFilePath = "wwwroot/json/homecoming/boost_sets/" + enhancementName + ".json"; string webRootPath = _env.WebRootPath; string jsonFilePath = Path.Combine(webRootPath, "json", "homecoming", "boost_sets", $"{enhancementName}.json"); All three above work locally just fine and all 3 give me the same error when deployed
Solution:
the good old .toLowerCase()
Jump to solution
17 Replies
Percy
Percy12mo ago
Project ID: 740eb4a0-07aa-4fed-aac4-d9d5028a12b8
Firi
Firi12mo ago
Project Id: 740eb4a0-07aa-4fed-aac4-d9d5028a12b8
Brody
Brody12mo ago
can we be sure this file or folder its in isnt being gitignored?
Firi
Firi12mo ago
One moment, let me check It is all there in my git repo
Brody
Brody12mo ago
okay next question, how big are these json files
Firi
Firi12mo ago
<100kb each
Brody
Brody12mo ago
should wwwroot be www/root ?
Firi
Firi12mo ago
No, /wwwroot is correct It doesn't seem to be finding the project dir maybe? It is {project}/wwwroot/...
Brody
Brody12mo ago
okay, can you share your repo so i can have a look at the folder structure?
Firi
Firi12mo ago
Yes, sent via dm
Brody
Brody12mo ago
#🛂|readme #5
Brody
Brody12mo ago
this has no capital letters
Brody
Brody12mo ago
this error does
Firi
Firi12mo ago
Okay, I will see if that will fix it
Solution
Brody
Brody12mo ago
the good old .toLowerCase()
Firi
Firi12mo ago
@Brody much appreciated, that fixed it
Brody
Brody12mo ago
no problem!