Hier also auch mal mein erstes Snippet.
Die Funktion bestimmt den Pfad der eigenen Anwendung. Dabei werden auch UNC-Pfade unterstützt.
Public Function Getselfdirectory() As String
Dim strselfdirectory As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
strselfdirectory = strselfdirectory.Replace("file:\", " ")
strselfdirectory = Trim(strselfdirectory)
If strselfdirectory.EndsWith("\") Then
If strselfdirectory.Contains(":") Then
Return strselfdirectory
Else
strselfdirectory = "\\" & strselfdirectory
Return strselfdirectory
End If
Return strselfdirectory
Else
If strselfdirectory.Contains(":") Then
Return strselfdirectory & "\"
Else
strselfdirectory = "\\" & strselfdirectory & "\"
Return strselfdirectory
End If
Return "\\" & strselfdirectory & "\"
End If
Return strselfdirectory
End Function
2 Kommentare zum Snippet