> Is there a standard way to retrieve the *relative* path to a "ProjectItem"
> file (relative to the project folder that is). Thanks.
You can always get the absolute path to the project item from the
object itself. You should be able to also get the project folder's
absolute path by getting the containing Project object for that project
item.
Now, in the SDK samples, there's a project called CodeSweep, which
contains a subfolder called Utilities. Here's the whole path ( under
the default installation):
C:\Program Files\Visual Studio 2005
SDK\2006.04\VisualStudioIntegration\Samples\IDE\CSharp\Example.CodeSweep\Utilities
Inside that folder, there's a file called "Utilities.cs" which has
several functions to make and resolve relative paths...
AbsolutePathFromRelative()
RelativizePathsIfPossible()
CanRelativize()
RelativePathFromAbsolute()
Hope that helps!
Larry Smith - 20 Jul 2006 21:44 GMT
>> Is there a standard way to retrieve the *relative* path to a
>> "ProjectItem"
[quoted text clipped - 19 lines]
> CanRelativize()
> RelativePathFromAbsolute()
Thanks very much. I already wrote my own since there seems to be no native
function available but I'll take a look at these examples anyway. Thanks
again.
John Torville - 26 Aug 2006 23:12 GMT
>>> Is there a standard way to retrieve the *relative* path to a
>>> "ProjectItem"
[quoted text clipped - 23 lines]
> function available but I'll take a look at these examples anyway. Thanks
> again.
"RelativePathFromAbsolute()" is broken (don't know about the others). I took
a brief look at it and it will fail for identical strings (throws an
exception) as well as calls like this:
// Eroneously returns "3":
RelativePathFromAbsolute("c:\\d1\\d23", "c:\\d1\\d2");
I know it's only sample code and easy enough to fix but I'd expect better
from MSFT (code that's released to the public - even sample code - should be
reviewed by *senior* developers first).