Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / August 2006

Tip: Looking for answers? Try searching our database.

Relative path to a "ProjectItem"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry Smith - 17 Jul 2006 14:59 GMT
Hi there,

Is there a standard way to retrieve the *relative* path to a "ProjectItem"
file (relative to the project folder that is). Thanks.
slush_puppy - 20 Jul 2006 19:58 GMT
> 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).

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.