|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
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
|
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Feb 2001
Città: Nordest
Messaggi: 217
|
Non occorre che usi le API, basta questa funzione:
Codice:
Public Function GetPathName(db As Database) As String
GetPathName = db.Properties("Name").Value
End Function
Codice:
path = GetPathName(CurrentDB)
__________________
Chi non cerca trova. |
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Feb 2001
Città: Reggio Emilia
Messaggi: 230
|
grazie mille
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 17:17.



















