C
C#•12mo ago
JohnStoober

Not gettting right pwd

Console.WriteLine(Directory.GetCurrentDirectory());
Console.WriteLine(Directory.GetCurrentDirectory());
only shows up to C:\Users\JohnStoober\ when I am really in C:\Users\JohnStoober\Repos\project\ am I doing something wrong?
17 Replies
Jimmacle
Jimmacle•12mo ago
how do you know you're really in that directory? if you create a file in the program, where does it end up?
JohnStoober
JohnStooberOP•12mo ago
lemme see wait, what would I use as the path?
Jimmacle
Jimmacle•12mo ago
nothing just a name of a file (spoiler: the thing you're doing wrong is almost definitely incorrectly assuming your PWD is something that it isn't)
JohnStoober
JohnStooberOP•12mo ago
File.Create() requires a path as arg
Jimmacle
Jimmacle•12mo ago
yes, so use a relative path which can be just the name of a file
JohnStoober
JohnStooberOP•12mo ago
o k it ends up in what the program thinks is my pwd
Jimmacle
Jimmacle•12mo ago
then that is 100% your pwd i can't tell you why, it depends on how you're running your program and any other code that may be setting your current directory
JohnStoober
JohnStooberOP•12mo ago
im in C:\Users\JohnStoober\Repos\project\ , even my shell says so
Jimmacle
Jimmacle•12mo ago
well, your program doesn't say so
JohnStoober
JohnStooberOP•12mo ago
so, any way I can perhaps fix this?
Jimmacle
Jimmacle•12mo ago
i mean, it's not broken you need to figure out what about your environment/configuration is setting the PWD to something you don't want
JohnStoober
JohnStooberOP•12mo ago
im almost sure it is; the $pwd variable points to my presumed current directory hmm
Jimmacle
Jimmacle•12mo ago
the core filesystem APIs in .NET are broken?
JohnStoober
JohnStooberOP•12mo ago
ok
Jimmacle
Jimmacle•12mo ago
which is more likely, that or something else 😛
JohnStoober
JohnStooberOP•12mo ago
maybe I just downloaded a corrupted version wait no thats not it hmmm, what could this be… this is so odd
hime
hime•12mo ago
How are you running your program
Want results from more Discord servers?
Add your server