I am starting a new thread on this because the last one I posted turned into a debate between randem and I.
I was wondering if anyone knew of a class module/DLL out there that finds the relative path of a file in a reliable manner. For example, I would pass these strings to a method:
"C:\Projects\My Project 1\Forms\MyForm.frm" <--- Path to make relative
"C:\Projects\My Project 1\" <--- Path to use as absolute
... should return ...
"\Forms\MyForm.frm"
Here is another example:
"C:\Common\By wossy\sandpaper.dll" <--- Path to make relative
"C:\Projects\My Project 1\" <--- Path to use as absolute
... should return ...
"..\..\Common\By wossy\sandpaper.dll"
There should also be another sub to unfold the relative paths. For example:
"D:\Another Guy\Coding Stuff\Project 132\" <--- Path to use as absolute
"\Forms\MyForm.frm"<--- Relative Path
... should return ...
"D:\Another Guy\Coding Stuff\Project 132\Forms\MyFrom.frm"
Does anyone know of a way to do this reliably? I have a feeling that if I wrote my own code to do it I would miss a few big things. This has to have been done before.
I guess I will just write it then. I think I will split() it on "\" (after replacing any "/" with "\") and then loop through and compare and take action when necessary.
In this case I did as you and in MakePathRelative you must end the path strings with a backslash to indicate a directory, if not it assumes it is the path to a file. In MakePathAbs the absolute path must be to a directory, but it doesn't matter if it has a trailing backslash or not since a directory is assumed. The relative path could be either to a file or a directory.
That is what I had been looking for for the last few days when I started 2 threads on this subject. After I finally get my act together and write some code, you show me what I wanted the whole time.
Thanks though! I'll take a look at it later today.
Well, I beg your pardon for not monitoring all the threads you start and immediatly reply to them . But the fact is that I didn't see this thread before you sent an e-mail to me about it