Get Relative File path

Bonekrusher

Active member
Joined
Jul 4, 2007
Messages
38
Programming Experience
1-3
Hi,

I am trying to create a small vb.net app that calculates the relative path from the Application.StartupPath.

The users uses the openfiledialog to select a file, this returns the absolute path. How can I calculate the relative path?

Application.StartupPath = "c:\temp\app_file

User selected path = "c:\myxmlfile.xml"


Desired relsult = "../../myxmlfile.xml"

Thanks
 
You should re-think the design. Usually there is no possible relative path from the drive your application is in and the drive the file is in.
 
I'd be interested to know how that could be relevant. Surely if you have an absolute path to a file then you don't need anything else. Also, what if the files are on different drives? As JohnH said, there won't be a valid relative path in that situation.
 
hi, its relative because i'm writing a plugin for an xml editior. relative paths are needed as the file system will be moved to a server.
 
Back
Top