Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

UrlPath Class - Path.Combine for URLs

RSS
Modified on Thu, Aug 13, 2015, 2:55 PM by Administrator Categorized as ASP·NET MVC, ASP·NET Web Forms
using System.Text;

public class UrlPath
{
    public static string Combine(params string[] items)
    {
        var sb = new StringBuilder();

        foreach (var item in items)
        {
            if (sb.Length > 0 && !sb.ToString().EndsWith("/"))
                sb.Append("/");

            if (sb.Length > 0 && item.StartsWith("/"))
                sb.Append(item.Substring(1));
            else
                sb.Append(item);
                    
        }

        return sb.ToString();
    }
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.