This question has been asked before but I don't seem to see my exact solution. I need to traverse some links in a file that are using relative paths and check whether or not they link to files that exist. Given the following files and folders:
C:\Level 1\Level 2\A.txt
C:\Level 1\B.txt
There might be a link in A.txt that links to B.txt using the relative path ..\B.txt.
I will have the current traversing directory, C:\Level 1\Level 2, and need to combine that with ..\B.txt to come up with C:\Level 1\B.txt so I can check the existence of B.txt.
I tried using Path.Combine but that didn't work. Any other thoughts? It would need to be able to support multiple levels like ..\..\..\D.txt.
Path.Combine? Given the paths that you described,Path.Combinereturned"C:\Level 1\Level 2\..\B.txt", which is a perfectly valid path that you can pass toFile.Exists.