R
Railway10mo 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
Percy10mo ago
Project ID: 740eb4a0-07aa-4fed-aac4-d9d5028a12b8
Firi
Firi10mo ago
Project Id: 740eb4a0-07aa-4fed-aac4-d9d5028a12b8
Brody
Brody10mo ago
can we be sure this file or folder its in isnt being gitignored?
Firi
Firi10mo ago
One moment, let me check It is all there in my git repo
Brody
Brody10mo ago
okay next question, how big are these json files
Firi
Firi10mo ago
<100kb each
Brody
Brody10mo ago
should wwwroot be www/root ?
Firi
Firi10mo ago
No, /wwwroot is correct It doesn't seem to be finding the project dir maybe? It is {project}/wwwroot/...
Brody
Brody10mo ago
okay, can you share your repo so i can have a look at the folder structure?
Firi
Firi10mo ago
Yes, sent via dm
Brody
Brody10mo ago
#🛂|readme #5
Brody
Brody10mo ago
this has no capital letters
Brody
Brody10mo ago
this error does
Firi
Firi10mo ago
Okay, I will see if that will fix it
Solution
Brody
Brody10mo ago
the good old .toLowerCase()
Firi
Firi10mo ago
@Brody much appreciated, that fixed it
Brody
Brody10mo ago
no problem!