hi, i just want to know when i new a Uri instance using the UriKind.Relative
para in construtor, where is the root path, for example, a local file
Uri u=new Uri("a.txt",UriKind.Relative);
then where is it? I thought it would be in the "object\debug" directory
where the exe file exists but nope
Can anyone tell me? I just want to get some local file using Uri with
relative path.
Thx in advanced
Peter Ritchie [C# MVP] - 19 Mar 2008 15:13 GMT
When you create a Uri as Relative it doesn't have any context. You have to
provide the context by merging a Relative Uri with an Absolute Uri. Your Uri
only contains "a.txt" (and many of the properties will throw an exception if
you try to use them).
It's a way of using a method that takes a Uri parameter without providing a
string or an Absolute Uri.

Signature
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
> hi, i just want to know when i new a Uri instance using the UriKind.Relative
> para in construtor, where is the root path, for example, a local file
[quoted text clipped - 4 lines]
> relative path.
> Thx in advanced
Paul E Collins - 19 Mar 2008 15:13 GMT
> hi, i just want to know when i new a Uri instance using the
> UriKind.Relative
> para in construtor, where is the root path, for example, a local file
> Uri u=new Uri("a.txt",UriKind.Relative);
> then where is it? I thought it would be in the "object\debug"
> directory
It's not anywhere, because it's a relative URI. It's just a fragment
that you can append to other URIs to make a longer one.
You want an absolute URI, not a relative one, since you know exactly
where your local file is.
Eq.