I have an absolute path to file A.
I have a relative path to file B from file A\'s directory. This path may and will use \"..\" to go up the directory structure in
I know it isn't the best solution but can't you just combine the substring of fileA's path from 0 to the lastIndexOf("\") with fileB's path.
Example A:
C:\projects\project1\module7\submodule5\fileAExample Bs:
..\..\module3\submodule9\subsubmodule32\fileBC:\projects\project1\module7\submodule5\..\..\module3\submodule9\subsubmodule32\fileB
If you don't want the .. in there then, it would take longer, but I recommend going through the path for fileB and keep taking the substring from 0 to the first index of \. Then check the substring. If it is .. then remove the substring from there and remove the substring from fileA's path from lastIndexOf(\) to length. Then repeat. That way you are removing the folders you don't need and the ..s.
So :
Example A:
C:\projects\project1\module7\submodule5\fileAExample Bs:
..\..\module3\submodule9\subsubmodule32\fileB
--> C:\projects\project1\module3\submodule9\subsubmodule32\fileB