View Single Post
Old 12-02-2003, 12:10   #1
CIUFFO
Member
 
L'Avatar di CIUFFO
 
Iscritto dal: Feb 2001
Cittā: Reggio Emilia
Messaggi: 230
OTTENERE IL PERCORSO DI UN FILE

Mi servirebbe ottenere la stringa del percorso completo di un file.
In Vb di una maschera di access ad esempio vorrei ottenere il percorso del file .mdb corrente.
Ho provato con GetAbsolutePathName e GetCurrentDirectory, ma mi danno un percorso non completo.
Ponendo ad esempio un DB in: C:\Documents and Settings\Giovanni\documenti\Mia cartella\mio file.mdb il codice sotto mi dā: C:\Documents and Settings\Giovanni\documenti\mio file.mdb !
Perchč mi taglia \Mia cartella\ ?
Codice:
Private Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
Private Sub Form_Load()
        Dim Buffer As String, Ret As Long
    'create a buffer
    Buffer = Space(255)
    'copy the current directory to the buffer and append 'myfile.ext'
    Ret = GetFullPathName("mio file.Mdb", 255, Buffer, "")
    'remove the unnecessary chr$(0)'s
    Buffer = Left(Buffer, Ret)
    'show the result
    MsgBox Buffer
End Sub
CIUFFO č offline   Rispondi citando il messaggio o parte di esso