How to combine URIs

前端 未结 5 1452
情话喂你
情话喂你 2020-12-15 17:54

I have two Uri objects passed into some code, one is a directory and the other is a filename (or a relative path)

var a = new Uri(\"file:///C:/Some/Dirs\");
         


        
5条回答
  •  余生分开走
    2020-12-15 18:35

    add a slash end of your first uri, URI will ignore more than one slash (/)

    var a = new Uri("file:///C:/Some/Dirs/");
    

    EDIT:

    var a = new Uri("file:///C:/Some/Dirs");
    var b = new Uri("some.file",  UriKind.Relative);
    var c = new Uri(Path.Combine(a.ToString(), b.ToString()));
    MessageBox.Show(c.AbsoluteUri);
    

提交回复
热议问题