Hi Rizaan,
If I understand correctly, what you are trying to do is easy in the example
you give as you are effectively just after the filename:
FileInfo fi = new FileInfo ( abPath ); // get a FileInfo for the file
specified in the absolute path
string relPath = fi.Name; // the name property returns the unqualified name
of the file
However, if the file you are after is in another directory then this is
quite a lot harder. I can't think of a way off the top of my head without
doing some sort of 'directory walk'.
You could walk from you absolute path to the root of your drive and then
walk down the path to your file, building the relative path as you go along.
This would work, but may not give you the most concise relative path
possible.
I am still not 100% sure I have understood what you are trying to do though.
Is it possible that the file you are after is in a different directory to
the absolute path given? Are you trying to build a relative path between a
directory and a file in another?
Apologies if it is obvious what you are saying and I am just missing the
point !
Rob
"Rizaan Jappie" <ri*****@korbitec.com> wrote in message
news:em****************@TK2MSFTNGP10.phx.gbl...
Sorry for being so vague Rob
what i need is the following :
If i have an absolute path to a file e.g.
c:\rizaan\pathsquestion\absolutepath\class1.cs
how would i go about getting the relative path in c# for class1.cs using
'c:\rizaan\pathsquestion\absolutepath\' as the source directory?
does this make sense at all?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!