© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
7 replies
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"
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()
Uri.TryCreate()
. they all return
false
false
for their
IsAbsoluteUri
IsAbsoluteUri
properties, when at least the second one should be
true
true
. I'm not sure what properties or methods I should utilize to obtain the information I'm after.

Any pointers/tips?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Parsing a Link from an HTML file with HTMLAgilityPack
C#CC# / help
3y ago
Parsing a binary file into a byte array
C#CC# / help
3y ago
❔ WPF a control to display an arbitrary object
C#CC# / help
3y ago