PathManipulate – A custom .Net Class for displaying long file paths in different formats

Here is a Class that can be used to display long filepaths in different formats depending on your needs. You can specify a desired length, the location of ellipses, and whether the filename is always displayed. It can also be used to return only the filename (with extension) when passed a full path.

Updates will be made to it as they’re available.

Hope someone finds it useful. Any efficiencies that can be made, let me know!

”’ Class allows the formatting of filepaths for displaying in different formats. All methods return a String object.
”’

Public Class PathManipulate

”’

”’ Returns the folder path that the supplied full filenpath resides in. Includes trailing ‘\’
”’

Public Function ShowDirectory(ByVal LongPath As String)
Dim FilePath As String
‘START AT BEGINNING OF FULL PATH AND END AT THE LAST OCCURRENCE OF ‘\’
FilePath = LongPath.Substring(0, LongPath.LastIndexOf(“\”) + 1)

Return FilePath
End Function

”’

”’ Returns only the filename (with extension) of the supplied filepath. Removes leading ‘\’.
”’