Autor Beitrag
Alpha_Wolf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 297

Ubuntu, Win XP, Win Vista
C#, Delphi 6 Prof, Delphi 2007 Prof, Java
BeitragVerfasst: Mi 10.08.05 08:52 
Hallo Leute,

bräuchte dringend eure Hilfe.. ich habe einen Pfad zB.: C:\Programme\Test\Zielordner

Ich bräuchte vom Zielordner das Erstellungesdatum und die Erstellungsuhrzeit. Das Ergebnis sollte halt dann ne TDateTime oder ne String variable gelegt werden.

Komm einfach nicht dahinter wie es gehen soll..

Habs versucht mit TSearchRec, FileAge und GetFileTime aber ich kriegs einfach nicht hin. Bin hier echt grad am verzweifeln :oops:


Danke für eure Hilfe!
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mi 10.08.05 08:55 
Poste mal deinen Code, macht die Fehlersuche einfacher.

_________________
Bravery calls my name in the sound of the wind in the night...
Alpha_Wolf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 297

Ubuntu, Win XP, Win Vista
C#, Delphi 6 Prof, Delphi 2007 Prof, Java
BeitragVerfasst: Mi 10.08.05 08:59 
Das Problem ist ich weiss einfach nicht wie ich zB bei SearchRec mit einem Pfad arbeiten soll..

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  SearchRec: TSearchRec;
begin

SearchRec.FindData.ftCreationTime;

end;

Code nicht funktionsfähig.

Wie gesagt ich steh aufm Schlauch wo ich bei TSearchRec da n Pfad angeben kann..
Logikmensch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 390

Win XP
Delphi 2007 Prof., XE2, XE5
BeitragVerfasst: Mi 10.08.05 09:18 
Hallo!

Also, die SearchRec-Struktur muss erst mit einem Findfirst initialisiert werden. Folgendes kleines Progrämmchen erläutert dies:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
    var
      sr:TSearchRec;
      dt:TDateTime;
 
    if FindFirst(Edit1.Text, faAnyFile, sr) = 0 then begin
      repeat
        if sr.Attr and faDirectory = faDirectory then begin
          dt:=FileDateToDateTime(sr.Time);
          showmessage(DateTimeToStr(dt));
        end;
      until FindNext(sr) <> 0;
      FindClose(sr);
    end;

ich hoffe, das funzt!

Liebe Grüße,

Claus.
Alpha_Wolf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 297

Ubuntu, Win XP, Win Vista
C#, Delphi 6 Prof, Delphi 2007 Prof, Java
BeitragVerfasst: Mi 10.08.05 09:35 
Das hat mir schonmal sehr geholfen dankeschön!!!

Mir fällt nur auf das er nie die richtige Uhrzeit ausgibt..

zB.:

C:\Programme

Windows sagt:
Montag, 4. April 2005, 09:08:45

Dein Code sagt:
04.04.2005 08:04:40

Woran liegt das bzw. was ist das dann für ein Datum bzw. welches ist dann richtig? :roll:
Logikmensch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 390

Win XP
Delphi 2007 Prof., XE2, XE5
BeitragVerfasst: Mi 10.08.05 12:23 
Hallo!

user profile iconAlpha_Wolf hat folgendes geschrieben:
Das hat mir schonmal sehr geholfen dankeschön!!!
<snip>
Windows sagt:
Montag, 4. April 2005, 09:08:45

Dein Code sagt:
04.04.2005 08:04:40

Woran liegt das bzw. was ist das dann für ein Datum bzw. welches ist dann richtig? :roll:


Hm, Windows führt zweierlei (oder mehr?) Datumsinformationen zu jeder Datei. Das ist zum einen das Erstellungsdatum, dann das des letzten Zugriffs. Welches Du brauchst, weiß ich jetzt auch nicht, aber vielleicht liefert der Zusatz FileAge die richtige Information:

ausblenden Delphi-Quelltext
1:
DateTimeToStr(FileDateToDateTime(FileAge(sr.FileName)))					


Viel Glück!

Claus.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 10.08.05 13:35 
Hallo,

Du warst mit SearchRec.FindData.ftCreationTime; schon auf dem richtigen Weg.

Diese Variablen noch im Code von user profile iconLogikmensch einbauen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var sC,
    sL_W,
    sL_A : String;
    LTime : TFileTime;
    Systemtime : TSystemtime;

dann den Code zusätzlich
an die entsprechende Stelle zw. Zeile 9: und 10: :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
  FileTimeToLocalFileTime( SR.FindData.ftCreationTime, LTime);
  FileTimeToSystemTime( LTime, SystemTime );
  SC := FormatDateTime('dd/mm/yyyy hh:nn:ss'
                       ,SystemTimeToDateTime( SystemTime));
  FileTimeToLocalFileTime( SR.FindData.ftLastWriteTime, LTime);
  FileTimeToSystemTime( LTime, SystemTime );
  sL_W := FormatDateTime('dd/mm/yyyy hh:nn:ss'
                       ,SystemTimeToDateTime( SystemTime));
  FileTimeToLocalFileTime( SR.FindData.ftLastAccessTime, LTime);
  FileTimeToSystemTime( LTime, SystemTime );
  sL_A := FormatDateTime('dd/mm/yyyy hh:nn:ss'
                         ,SystemTimeToDateTime( SystemTime));

Zwischen der Zeit von sr.Time und SR.FindData.ftLastAccessTime habe ich eine Abweichung von ca. 0 bis 3 Sekunden festgestellt.
Der Explorer zeigt die Zeit von ftLastAccessTime an.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Alpha_Wolf Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 297

Ubuntu, Win XP, Win Vista
C#, Delphi 6 Prof, Delphi 2007 Prof, Java
BeitragVerfasst: Mi 10.08.05 14:58 
Hey super dankeschön!

Da steckt doch mehr dahinter als man denkt.. :D
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mi 10.08.05 22:22 
Hallo,

bitteschön :wink:
wäre nett wenn Du den Thread auch entsprechend markieren würdest!

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )