C
C#•17mo ago
Calvin

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

Did you find this page helpful?