C
C#•6mo 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•6mo 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
JohnStoober•6mo ago
lemme see wait, what would I use as the path?
Jimmacle
Jimmacle•6mo 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
JohnStoober•6mo ago
File.Create() requires a path as arg
Jimmacle
Jimmacle•6mo ago
yes, so use a relative path which can be just the name of a file
JohnStoober
JohnStoober•6mo ago
o k it ends up in what the program thinks is my pwd
Jimmacle
Jimmacle•6mo 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
JohnStoober•6mo ago
im in C:\Users\JohnStoober\Repos\project\ , even my shell says so
Jimmacle
Jimmacle•6mo ago
well, your program doesn't say so
JohnStoober
JohnStoober•6mo ago
so, any way I can perhaps fix this?
Jimmacle
Jimmacle•6mo 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
JohnStoober•6mo ago
im almost sure it is; the $pwd variable points to my presumed current directory hmm
Jimmacle
Jimmacle•6mo ago
the core filesystem APIs in .NET are broken?
JohnStoober
JohnStoober•6mo ago
ok
Jimmacle
Jimmacle•6mo ago
which is more likely, that or something else 😛
JohnStoober
JohnStoober•6mo ago
maybe I just downloaded a corrupted version wait no thats not it hmmm, what could this be… this is so odd
hime
hime•6mo ago
How are you running your program