Am I using the Path.Combine
Method Incorrectly?
I Get This Result With Path.Combine(string[])
:
C:Users\\\\Admin\\\\AppData\\\\R
It's in the documentation:
If
path1
is not a drive reference (that is, "C:" or "D:") and does not end with a valid separator character [..],DirectorySeparatorChar
is appended topath1
before concatenation.
So your first path, which is the drive letter, does not get a directory separator appended. You can for example fix this after splitting, by appending the separator to TempSave[0]
, but that'll cause issues with Linux like you said.
You can also solve your actual problem differently, see How do I find the parent directory in C#?, or just append ..\..\
like @Dan suggests so you can skip the splitting:
string desiredPath = Path.Combine(Application.UserAppDataPath, @"..\..\");