❔ Path.GetFullPath behavior on linux
how to get full path correctly? if i use
/home/x/deep as abs it works fine and gives /home/x/test.txt. im on linux.
12 Replies
correct behavior

Backslashes aren't part of the directory structure on linux, and
C: isn't a linux thing at all
So the path you specified in your first screenshot is processed as a folder called c:\home\x\deep\.. and a file called text.txti would like to format these strings regardless of the os
for sake of testing
no file would be actually accessed
You can remove the
c: part, and replace all \s with /sok i will try it. thanks
what if i run this inside windows? will it respect the / and give the same result? i dont have windows machine atm
since / is also a valid separator on windows afaik
It will understand
/ properly on windows, yes
I don't know what it does if it starts with / thoughtried with online compiler that runs on windows and gives this instead. so it is treated as relative path

if i use /home instead

i'm not sure why you want to hardcode the same path on Windows and Linux
And also, I don't think C:\home would be preferred home path in windows. Try to access the environment variable userprofile
,
Was this issue resolved? If so, run
/close - otherwise I will mark this as stale and this post will be archived until there is new activity.