Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How do I programatically get file meta data including owner, last file access, size etc.

Posted on 2009-05-01
4
Medium Priority
?
439 Views
Last Modified: 2013-11-27
I am trying to import file Meta data into an application, which is at this stage being designed in AccessVBA. The spec of the data I require for the files it finds in a search include name, size, owner, last access.

I can easily search for files using VBA, that is not a problem, but I cannot get back the granularity of information about the files that I need. Using VBA to search large drives, folders and sub folders is also quite slow.

Is there a way of calling a windows procedure that will run return the data to the calling proc.

I would be grateful if anyone can pointg me in the right direction as I cannot find a way of getting the file data  I need.

I am working with file data on a Windows Servcer 2003 standard server and Access 2003 VBA.  

0
Comment
Question by:DavidHannen
  • 2
  • 2
4 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 24278140
If you got your search going, how about inserting into a table as you go along?

eg create a table called tblFileInfo with the relevant fields
eg
fname (filename)
crtdate (created date)
upddate (updated date)
upduser (updated user)

as you find each file, insert a record

then caller simply has to query this table
0
 

Author Comment

by:DavidHannen
ID: 24278237
Thanks Rockiroads:

But I don't have a problem dealing with data once it reaches the application - my issues are about getting the meta data in the first plsce and the fastest way of doing it. (probably a call outside VBA)

Whilst I can get file names from a search using VBA directly I cannot get owner and last opened date.

Thanks
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 24278238
Ive knocked up an example, but I cant get the owner name, however I have a link which perhaps you can use.
Revise the table as you want filename, size, owner and last access
so fieldnames I guess could be FName, Size, Owner, LastAccess

Public Function SaveFileInfo()

    Dim rs As DAO.Recordset
    Dim i As Long
    Dim fs As object
    Dim f As object

    Set rs = CurrentDb.OpenRecordset("select * from tblFileInfo")
    Set fs = createobject("Scripting.FileSystemObject")

    With Application.FileSearch
        .NewSearch
        .LookIn = "C:\mystartdir\"
        .SearchSubFolders = True
        .FileName = "*.*"
        .Execute                                            '<--- THIS IS THE SLOW BIT
        For i = 1 To .FoundFiles.count
       
            Set f = fs.GetFile(.FoundFiles(i))
           
            rs.AddNew
'Save filename
            rs!FName = .FoundFiles(i)
'Save last last access date
            rs!LastAccess = f.DateLastAccessed
'Save size
            rs!Size = f.Size

'See this link to get owner http://www.microsoft.com/technet/scriptcenter/resources/qanda/oct04/hey1007.mspx
            rs.Update
        Next i
    End With

    rs.close
    set rs=nothing
    set fs=nothing
End Function
0
 

Author Closing Comment

by:DavidHannen
ID: 31576846
Thanks, I  have all the file system object stuff - but the link to the scripting Guy article will be invaluable. Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have had my own IT business for a very long time. I started mostly with hardware and after about a year started to notice a common theme. I had shelves with software boxes -- Peachtree, Quicken, Sage, Ouickbooks -- and yet most of my clients were…
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question