Reputation: 709
I'm searching for a datatype to store UNC paths in. I already tried using Uri but I always get an UriFormatException
telling me
Invalid URI: The hostname could not be parsed.
The UNC path I'm using is \\.\Dap0
which represents a Data Acquisition Processor
I'm working with.
Does anyone know such a datatype? Maybe one which makes it possible to work with the path? Or did I miss something when using Uri
?
Does the path need to be accessible when creating an Uri
object? Because currently it isn't, I'm only using this path for testing purposes.
Upvotes: 2
Views: 446
Reputation: 11871
Uri is the right framework class for UNC paths and even has an IsUncPath method to validate this.
The problem here is you're using \\.\
which is not a standard UNC path and is used to access the Win32 device namespace. You can see here for more details.
Note that (from the document linked above):
Most APIs won't support "\.\"; only those that are designed to work with the device namespace will recognize it. Always check the reference topic for each API to be sure.
So in your specific situation you are probably going to have work with a string
or roll your own class.
Upvotes: 1