about the Uri relative path

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?ZmFpcnl2b2ljZQ==?=

    about the Uri relative path

    hi, i just want to know when i new a Uri instance using the UriKind.Relativ e
    para in construtor, where is the root path, for example, a local file
    Uri u=new Uri("a.txt",Uri Kind.Relative);
    then where is it? I thought it would be in the "object\deb ug" 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
  • Paul E Collins

    #2
    Re: about the Uri relative path

    "fairyvoice " <fairyvoice@dis cussions.micros oft.comwrote:
    hi, i just want to know when i new a Uri instance using the
    UriKind.Relativ e
    para in construtor, where is the root path, for example, a local file
    Uri u=new Uri("a.txt",Uri Kind.Relative);
    then where is it? I thought it would be in the "object\deb ug"
    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.


    Comment

    • =?Utf-8?B?UGV0ZXIgUml0Y2hpZSBbQyMgTVZQXQ==?=

      #3
      RE: about the Uri relative path

      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.

      --
      Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.

      Microsoft MVP, Visual Developer - Visual C#


      "fairyvoice " wrote:
      hi, i just want to know when i new a Uri instance using the UriKind.Relativ e
      para in construtor, where is the root path, for example, a local file
      Uri u=new Uri("a.txt",Uri Kind.Relative);
      then where is it? I thought it would be in the "object\deb ug" 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

      Comment

      Working...