Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

Getting the properties of a file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vilem Sova - 26 Sep 2006 11:11 GMT
I need to be able to get some properties from files stored on a server (in
particular the date modified and size).

I've come across the FileSystemObject on the TheAccessWeb web site, but it
requires installing and registering dll's and VB runtimes and the like.

Is there another, simpler way to get these properties?

Thanks
Vilem Sova
Douglas J. Steele - 26 Sep 2006 13:03 GMT
The FileDateTime function will return the date and time the file was last
modified.

The FileLen function will return the length of the file in bytes.

Both functions take a single argument: the full path to the file.

Having said that, unless you're using really old operating systems, you
should be able to use FSO without any problems. It's not even necessary to
set a reference to it in Access: you can use Late Binding instead.

Sub UsingFSO(FilePath As String)

Dim objFSO As Object
Dim objFile As Object
Dim strOutput As String

 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objFile = objFSO.GetFile(FilePath)
 strOutput = FilePath & " is " & objFile.Size & _
   " bytes, and was last modified " & _
   objFile.DateLastModified
 MsgBox strOutput

End Sub

For what it's worth, I rarely, if ever, use FSO. Using APIs is significantly
faster. Tests I did enumerating files on a hard drive showed using APIs to
be an order of magnitude faster than using VBA functions, and the VBA
functions were an order of magnitude faster than using FSO.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I need to be able to get some properties from files stored on a server (in
>particular the date modified and size).
[quoted text clipped - 6 lines]
> Thanks
> Vilem Sova
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.