Calculate Relative Path : Path « File Stream « C# / C Sharp
- C# / C Sharp
- File Stream
- Path
Calculate Relative Path
//-----------------------------------------------------------------------
// <copyright file="PathUtil.cs" company="INL sprl">
// Copyright 2010 INL sprl.
// </copyright>
// Fabrice avaux : Date de cration 16/10/2010
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
internal static class PathUtil
{
internal static string GetRelativePath(string rootPath, string fullPath)
{
rootPath = System.IO.Path.GetFullPath(rootPath).ToLowerInvariant();
string lowerfullPath = System.IO.Path.GetFullPath(fullPath).ToLowerInvariant();
if (!lowerfullPath.StartsWith(rootPath))
return fullPath;
return fullPath.Substring(rootPath.Length);
}
}
Related examples in the same category