List<string> paths = new List<string>()
{
@"C:\users\MyPc\UsersData\Users",
@"C:\users\MyPc\UsersData\Users\Data",
@"C:\users\MyPc\UsersData\Users\Data\Anagraphics",
@"C:\users\MyPc\UsersData\Work"
};
var MatchingChars =
from len in Enumerable.Range(0, paths.Min(s => s.Length)).Reverse()
let possibleMatch = paths.First().Substring(0, len)
where paths.All(f => f.StartsWith(possibleMatch))
select possibleMatch;
var LongestDir = Path.GetDirectoryName(MatchingChars.First());
var ftpPaths = paths.Select(p=>Path.Combine("myftp:8008",p.Substring(LongestDir.Length +1)).Replace(@"\", "/"));
ftpPaths :
myftp:8008/Users
myftp:8008/Users/Data
myftp:8008/Users/Data/Anagraphics
myftp:8008/Work
To Find the common file path from list of paths I used one of answer of this SO Question