C#C
C#3y ago
Kiel

Parsing an arbitrary file path as a Uri or similar

Hello there. I would like to be able to parse the following inputs in such a way that I'm aware if they are a relative or absolute path:
path/to/file.txt -> "Relative"
/path/to/file.txt -> "Absolute"
./path/to/file.txt -> "Relative"

I'm having trouble getting this to work with Uri.TryCreate(). they all return
false
for their IsAbsoluteUri properties, when at least the second one should be
true
. I'm not sure what properties or methods I should utilize to obtain the information I'm after.

Any pointers/tips?
Was this page helpful?