Shorten too long file path in VB
''' <summary> ''' Diese Funktion kürzt einen Pfad ab so das aus ''' "C:\Windows\System32\Test\Test.dll" dann "C:\Windows\...\Test.dll" wird ''' </summary> ''' <param name="Path">Der Pfad der gekürzt zurückgegeben werden soll</param> ''' <param name="Length">Die gewünschte Länge die nicht überschritten werden darf</param> ''' <param name="TextFont">Die Schriftart die angewendet wird</param> Public Function PathShorten(ByVal Path As String, ByVal Length As Integer, ByVal TextFont As Font) As String Dim PathParts() As String = Split(Path, "\") Dim PathBuild As New System.Text.StringBuilder(Path.Length) Dim LastPart As String = PathParts(PathParts.Length - 1) Dim PrevPath As String = "" 'Erst prüfen ob der komplette String evtl. bereits kürzer als die Maximallänge ist If TextRenderer.MeasureText(Path, TextFont).Width < Length Then Return Path End If For i As Integer = 0 To PathParts.Length - 1 PathBuild.Append(PathParts(i) & "\") If TextRenderer.MeasureText(PathBuild.ToString & "...\" & LastPart, TextFont).Width >= Length Then Return PrevPath Else PrevPath = PathBuild.ToString & "...\" & LastPart End If Next Return PrevPath End Function
Shortens a long path to a way shorter path. For example: "C:\Windows\System32\Test\Test.dll" to "C:\Windows\...\Test.dll"
Anonymous on Feb 21, 2010
udlxji <a href="http://pknrhibmajop.com/">pknrhibmajop</a>, [url=http://sjxhkuuffhgw.com/]sjxhkuuffhgw[/url], [link=http://htccvnviifms.com/]htccvnviifms[/link], http://fvvfezirjsgt.com/
Anonymous on Mar 14, 2010
aPFEfc <a href="http://mvwnbjxohbwh.com/">mvwnbjxohbwh</a>, [url=http://xhlttjtnexjm.com/]xhlttjtnexjm[/url], [link=http://ofbuindbkxtq.com/]ofbuindbkxtq[/link], http://bxzqmruerqoc.com/