General |
6.200 Dall'indirizzo completo di un file estrarre solamente il nome della directory che contiene il file |
Alessandro Baraldi |
Con la funzione che segue si ottiene dall'indirizzo completo di un file solo l'indirizzo della directory che lo contiene. Public Function GetPathPart(ByVal strPath As String) As String '***************************************************************** 'Name : GetPathPart (Function) 'Purpose : Return Path name ONLY 'Author : Alessandro Baraldi 'E.Mail : ik2zok@libero.it 'Date : 23 gennaio 2002 '***************************************************************** Dim intCounter As Integer For intCounter = Len(strPath) To 1 Step -1 If Mid$(strPath, intCounter, 1) = "\" Then Exit For End If Next intCounter GetPathPart = Left$(strPath, intCounter) End FunctionSe ad esempio l'indirizzo completo del file fosse C:\Programmi\DataBase.mdb, la funzione di cui sopra ritornerebbe la stringa C:\Programmi\. |