Question: 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");
var b = new Uri("some.file");

```

when I try and combine them like this:

```
var c = new Uri(a,b);

```

I get 

> 
> `file:///C:/Some/some.file`
> 
> 
> 

where I wold expect to get the same effect as with `Path.Combine` (as that is the old code I need to replace):

> 
> `file:///C:/Some/Dirs/some.file`
> 
> 
> 

I can't think of a clean solution to this.

The ugly solution being to add a `/` to the Uri if it's not there

```
string s = a.OriginalString;
if(s[s.Length-1] != '/')
   a = new Uri(s + "/");

```

Answer: 
You can try this extension method! Works always! ;-)

```
 public static class StringExtension
    {
        public static string UriCombine(this string str, string param)
        {
            if (!str.EndsWith("/"))
            {
                str = str + "/";
            }
            var uri = new Uri(str);
            return new Uri(uri, param).AbsoluteUri;
        }
    }

```

Angelo, Alessandro
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);

```