Re: Dateigröße und Zeit

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Henry Habermacher [MVP Access] (DontSpamHenry_at_psp-online.com)
Date: 03/30/04


Date: Tue, 30 Mar 2004 14:10:08 +0700

Hallo Mihael

Mihael Ryda wrote in news:1565001c415a4$f5b69520$a101280a@phx.gbl:
> Bevor mich jemand daran erinnern will :-)
>
> Ja ich habe das Forum 4 Jahre zurück durchsucht.
>
> WinXP/AccessXP/2003
>
> Wie kann ich bitte die Zeit und Größe einer Datei auf der
> HD auslesen. zb: C:\Test.txt

4 Jahre zurück nützt nichts, weil es da A2002/2003 und WinXP gar noch
nicht gegeben hat.
Ich habe auch gesucht aber in der VBA Hilfe von Access mit den
Stichworten "file date" im Hilfe Dropdown oben rechts im VBA Editor
Toolbar und sofort folgendes gefunden: "DateLastModified Property"
(c) Microsoft:
----- zitat -----
DateLastModified Property
Description
Returns the date and time that the specified file or folder was last
modified. Read-only.
Syntax
object.DateLastModified
The object is always a File or Folder object.
Remarks
The following code illustrates the use of the DateLastModified property
with a file:
Sub ShowFileAccessInfo(filespec)
    Dim fs, f, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespec)
    s = UCase(filespec) & vbCrLf
    s = s & "Created: " & f.DateCreated & vbCrLf
    s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
    s = s & "Last Modified: " & f.DateLastModified
    MsgBox s, 0, "File Access Info"
End Sub
---- Ende Zitat ----

Selbstverständlich erschien da auch die von Karl bereits genannte
FileDateTime Funktion.

Das FileSystemObject ist für solche Informationen immer gut.
Selbstverständlich solltest Du das noch ein bisschen an VBA anpassen,
also z.B.

Dim fs as Object
Dim f as Object
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("Pfad und Name der Datei")
MsgBox "LastModified=" & f.DateLastModified
MsgBox "FileSize=" & f.Size
Set f = nothing
Set fs = nothing

Da lassen sich auch noch viele andere Eigenschaften herauslesen, wie
z.B. der kurze und lange Dateinamen und/oder Pfadnamen, wann die Datei
das letzte Mal angefasst wurde (bedingt allerdings IIRC das NTFS
Dateisystem), etc. etc.

Die einfachere Lösung hast Du von Karl ja bereits erhalten, wollte halt
auch noch ein bisschen was schreiben, dass das in der OH von Access
schon drin ist.;-)

Gruss
Henry

-- 
Keine E-Mails auf Postings in NGs senden!
Don't send e-mails to postings in newsgroups!
KB:  http://support.microsoft.com/default.aspx
FAQ: http://www.donkarl.com/FAQ/FAQStart.htm
OH:  Online Hilfe von Microsoft Access (Taste F1)
Downloads: http://www.dbdev.org


Relevant Pages