Answer by Jonathan Leffler for How to get relative path from absolute path
As Alex Brault points out, especially on Windows, the absolute path (with drive letter and all) is unambiguous and often better.Shouldn't your OpenFileDialog use a regular tree-browser structure?To get...
View ArticleAnswer by DavidK for How to get relative path from absolute path
There is a Win32 (C++) function in shlwapi.dll that does exactly what you want: PathRelativePathTo()I'm not aware of any way to access this from .NET other than to P/Invoke it, though.
View ArticleAnswer by 3Doubloons for How to get relative path from absolute path
I'd split both of your paths at the directory level. From there, find the point of divergence and work your way back to the assembly folder, prepending a '../' everytime you pass a directory.Keep in...
View ArticleAnswer by Kevin for How to get relative path from absolute path
Use:RelPath = AbsPath.Replace(ApplicationPath, ".")
View ArticleHow to get relative path from absolute path
There's a part in my apps that displays the file path loaded by the user through OpenFileDialog. It's taking up too much space to display the whole path, but I don't want to display only the filename...
View Article