In C ++, windows, I have 2 file paths:
- Path 1 / Strong>: Directory
- Path2 : file or directory
How can I tell that Path2 is descended from Path1? Is there a shell function for that? I have searched the Shell API and no one can get it.
Note: I do not want to compare the string by itself, unless there is no safe way to make the path comparable (abbreviation, relative items, etc ...).
You can use to compare two paths to get a normal prefix. Then compare the normal prefix in Path 1 (your directory).
If both are equal, then Path2 should be a descendant
Or you can participate without using
outside buffer for the third parameter and Just pass the
null and check that the return value, which is the calculation of the normal prefix letter, is equal to the length of path 1. From a doctor's example of PathCommonPrefix , this is not included in the
PathCommonPrefix followed by the Directory Separator in the 'General' prefix, so that you can get the first in Path 1 The oyster will have to touch or after that there will be a need to adjust its comparison as a result of the lack behind the CP.
- Path2 : file or directory
Comments
Post a Comment