Relative file path
-
In my application, I want the user to be able to customize the path to some files. So I use a OpenFileDialog, and get the path of the new file, and I can open the file. I'd like to store the path for the next use of the program, but I want to store it relatively to my executable. But the OpenFileDialog return the absolute path. So if I have: e:\Programs\MyProgram\Bin\MyExecutable.exe and the user select e:\Programs\MyPrograms\Graphics\MyFile.gif How can I easily find that the path to store is ..\Graphics\MyFile.gif?
-
In my application, I want the user to be able to customize the path to some files. So I use a OpenFileDialog, and get the path of the new file, and I can open the file. I'd like to store the path for the next use of the program, but I want to store it relatively to my executable. But the OpenFileDialog return the absolute path. So if I have: e:\Programs\MyProgram\Bin\MyExecutable.exe and the user select e:\Programs\MyPrograms\Graphics\MyFile.gif How can I easily find that the path to store is ..\Graphics\MyFile.gif?
In shlwapi.dll there is a method called
PathRelativePathTo
.α.γεεκ
Fortune passes everywhere.
Duke Leto Atreides