how to extract common file path from list of file paths in c#

后端 未结 9 1506
粉色の甜心
粉色の甜心 2021-01-17 15:42

What is the best way extract the common file path from the list of file path strings in c#?

Eg: I have a list 5 file paths in List variable, like below

c:\

9条回答
  •  独厮守ぢ
    2021-01-17 16:32

    The selected solution does not work properly if one of the paths is exactly the directory name that should be returned. I think there should be:

    from len in Enumerable.Range(0, matchingNames.Min(s => s.Length) + 1).Reverse()

提交回复
热议问题