Reputation: 368
I have a file on mac which is at /Users/Bsh/Desktop/myProgram/myFile.txt
when I use this address instead of Path.GetFullPath("myFile.txt")
in the C# program, the file is found by the program but when I use Path.GetFullPath("myFile.txt")
the program does not find the file. To find out what Path.GetFullPath
returns, I used Console.WriteLine(Path.GetFullPath("myFile.txt"));
and the output was /Users/Bsh/Desktop/myProgram/bin/Debug/netcoreapp3.0/myFile.txt
.
Why is there an extra part: bin/Debug/netcoreapp3.0
? And how to resolve the issue?
Thanks.
Upvotes: 0
Views: 955
Reputation: 32780
The first step you should take when a library method is not working as expected, is Read The Documentation.
In particular, you should be paying special attention to this part:
This method uses the current directory and current volume information to fully qualify path. If you specify a file name only in path,
GetFullPath
returns the fully qualified path of the current directory.
The answer to your question seems rather obvious.
Upvotes: 1