I’m also struggling to find an answer, googling for hours, but I’m afraid a neat function is not available yet :(.
So, as ugly as your shell command work-around may look, you might as well stick with it.
The “closest” piece of code I got, I found here:
Sub Test()
proprietesFichier_getFile "C:\Documents and Settings\mimi\dossier\Nom Classeur.xls"
proprietesFichier_getFile "C:\dossier\monAppli.exe"
proprietesFichier_getFile "C:\dossier\le fichier.pdf"
End Sub
Sub proprietesFichier_getFile( Fichier As String )
Dim oObj As Object , Cible As Object
Dim Valeur As Object
Dim Resultat As String
oObj = createUnoService("com.sun.star.bridge.OleObjectFactory")
Cible = oObj.createInstance("Scripting.fileSystemObject")
Valeur = Cible.GetFile(Fichier)
Resultat = "Chemin : " & Valeur.ParentFolder.Path & Chr(10) & Chr(10) & _
"Chemin court : " & Valeur.shortpath & Chr(10) & Chr(10) & _
"Nom court : " & Valeur.ShortName & Chr(10) & Chr(10) & _
"Date creation : " & CDate( Valeur.DateCreated.Value ) & Chr(10) & Chr(10) & _
"Date derniere modification : " & CDate( Valeur.DateLastModified.Value ) & Chr(10) & Chr(10) & _
"Date dernier acces : " & CDate( Valeur.DateLastAccessed.Value ) & Chr(10) & Chr(10) & _
"Taille fichier : " & Valeur.Size & " octets" & Chr(10) & Chr(10) & _
"Type fichier : " & Valeur.Type & Chr(10) & Chr(10) & _
"Extension fichier : " & Cible.GetExtensionName(Valeur) & Chr(10) & Chr(10) & _
"Nom fichier sans extension : " & Cible.GetBaseName(Valeur) & Chr(10) & Chr(10) & _
"Nom fichier : " & Cible.GetFileName(Valeur) & Chr(10) & Chr(10) & _
"Chemin et nom complet : " & Cible.GetAbsolutePathName(Valeur)
MsgBox Resultat
End Sub
Which is a bit elaborate, and alas fails reaching:
Cible = oObj.createInstance("Scripting.fileSystemObject")
which i suppose only works in M$ Visual Basic.
In the meanwhile however, my solution lies in this simple piece of code (with imperfect function FileLen() returning a “long” ) inspired from here:
Function dFileSizeInKb(sMediaFilePath) as Double
Dim dMediaFileLength as double
dMediaFileLength = FileLen(sMediaFilePath)
if dMediaFileLength < 0 then
dMediaFileLength = 2^32 + dMediaFileLength
end if
dFileSizeInKb = dMediaFileLength
End Function
BTW, Could you please share this shell command work-around of yours. This would be much apreciated.
Thanks very much in advance