以下は私の文字列です。次のような操作を行いたい: URL に「Destinationfolder」が含まれている場合、folder1 と folder2 を取得する必要があり、結果を別の文字列に 1 つずつ割り当てる必要があります。
string strpath = @"D:\Multilingual\Destinationfolder\folder1\folder2";
ループでPath.GetDirectoryNameメソッドを使用できます。
string strpath = @"D:\Multilingual\Destinationfolder\folder1\folder2";
string folderToFind = "Destinationfolder";
var subfolders = new List<string>();
if (strpath.Contains("Destinationfolder"))
{
subfolders.AddRange(Regex.Replace(strpath, @".*"+folderToFind, "")
.Trim('\\')
.Split('\\'));
}