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