It happens that your application encounters a directory path that is relative to current folder or uses double dot for navigation, e.g. C:\A\B\..\C
. This obviously is equivalent to the canonical path C:\A\C
. How can one resolve the path to its canonical form?
This one uses the java io interface:
jFile=java.io.File(iPath);
oPath=jFile.getCanonicalPath;
It wouldn't need to change matlab's directory. It has other useful methods that may be found here.
The simplest way I know to convert a path to its canonical form is using cd
command:
oPath = cd(cd(iPath));
Note that this would fail if the path does not exist on your file system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With