C
C#3y ago
gumbarros

Path.Combine to folder behind

Why this is not working?
var root = Path.Combine("/../","/../", builder.Environment.ContentRootPath);
var sharedSettings = Path.Combine(root, "appsettings.json");
var root = Path.Combine("/../","/../", builder.Environment.ContentRootPath);
var sharedSettings = Path.Combine(root, "appsettings.json");
8 Replies
gumbarros
gumbarrosOP3y ago
Output:
gumbarros
gumbarrosOP3y ago
gumbarros
gumbarrosOP3y ago
Expected output: /home/gumbarros/Projects/jjmasterdata/appsettings.json
ero
ero3y ago
"/../" can't be a valid starting path You probably want Path.Join(builder.Environment.ContentRootPath, "..", "..");
canton7
canton73y ago
Path.Combine does weird stuff when one of the parts starts with / as well, that's why we now have Path.Join. But use ".." either way, as @Ero did
HimmDawg
HimmDawg3y ago
Path.Join is .NET7 tho iirc
ero
ero3y ago
gumbarros
gumbarrosOP3y ago
Solved, thanks
Want results from more Discord servers?
Add your server