How to check if directory 1 is a subdirectory of dir2 and vice versa
问题 What is an easy way to check if directory 1 is a subdirectory of directory 2 and vice versa? I checked the Path and DirectoryInfo helperclasses but found no system-ready function for this. I thought it would be in there somewhere. Do you guys have an idea where to find this? I tried writing a check myself, but it's more complicated than I had anticipated when I started. 回答1: You can compare directory2 to directory1's Parent property when using a DirectoryInfo in both cases. DirectoryInfo d1 =