I have a List
that contains all the remote Path I need
List<string> remotePath = MyTableWithRemotePath.Select(i => i.ID_SERVER_PATH).ToList();
I have a string which is the server I'm finding.
string remotePath = "Path I'm looking for";
I have to find which is the path of the list which match better with the one I'm looking for.
I tried with this but it doesn't work
var matchingvalues = remotePath.FirstOrDefault(stringToCheck => stringToCheck.Contains(remotePath));
Any suggestions?
EDIT
Example:
I have to find the best match for this path: C:\\something\\location\\
This is my List:
- C:\\something\\location\\XX\\
- C:\\something\\location2\\YY\\
- C:\\something\\location3\\AA\\
- C:\\something\\location4\\CS\\
The result have to be the first element:
C:\\something\\location\\directory\\