Autor Beitrag
bocky3
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Sa 23.04.05 01:12 
ich hab ein rätsel erstellt.
man hat die möglichkeit seine ergebnisse zuspeichern, aber ich möchte dass, das prog die save-datei automaisch beim start nach ablauf von ca 30 tagen löscht.
die save.bocky (save datei) wird in "/bilder/save.bocky" gespeichert.
habt ihr ne idee?
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Sa 23.04.05 14:39 
dann frag ich ma anders:
gibt es ne möglichkeit das erstellungsdatum einer datei in einem delphiprog auszulesen?
und
gibt es einen befehl zum löschen von dateien?

das is das was ich bräuchte
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 23.04.05 14:42 
da gibts diverse Möglichkeiten. Z.B. Fileage + filedatetodatetime und deletefile, dazu sagt die OH auch recht viel.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Sa 23.04.05 15:08 
das deletefile funzt ganz gut.
ich hab aber grad nen prob mit dem laden
ich möchte gern, dass das prog überprüft ob eine save.bocky da is, wenn ja soll es deise laden, wenn nich soll es über showmessage ('keine datei vorhanden') bringen.
ich würd das ganze gerne mit ner if schleife machen wenn möglich.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
if {...} then
 begin
  List:=TStringList.Create;
  List.LoadFromFile('bilder\save.bocky');
  Edit1.Text:=List[0];
  Edit2.Text:=List[1];
  Edit3.Text:=List[2];
  Edit4.Text:=List[3];
  Edit5.Text:=List[4];
  List.Free;
 end;
else
showmessage('keine datei vorhanden');


Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 23.04.05 15:13 
user profile iconbocky3 hat folgendes geschrieben:
ich würd das ganze gerne mit ner if schleife machen wenn möglich.
Guckst du hier: www.if-schleife.de

Ne, im Ernst: Du suchst den Befehl FileExists(); Mehr dazu in der Delphi-Hilfe

_________________
We are, we were and will not be.
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Sa 23.04.05 15:50 
also ich hab jetzt das versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
if FileExists('bilder\save.bocky'then
   begin
    DOSDatum:=FileAge(Dateiname);
    WinDatum:=FileDateToDateTime(DOSDatum);
     if Windatum = > 30 then       // hier is der fehler 
      begin
       DeleteFile('bilder\save.bocky');
      end
   end;


ich weiß nich wie die funktion "FileDateToDateTime(DOSDatum)" das datum ausgibt bzw. wie ich es mit der frist von 30 tagen vergleichen soll.


mfg burn
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 23.04.05 15:52 
gugg dir mal Tdatetime in der Hilfe an, da kommt du mit ganz wenig Mathe von alleine drauf.

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Sa 23.04.05 16:19 
tag/monat/jahr?
dann müsste:
if jetziges datum - entstehungsdatum = > 30 then
begin
DeleteFile('bilder\save.bocky');
end;
is das korrekt (nur in form des verständnisses)
bocky3 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: So 24.04.05 00:39 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  if FileExists('bilder\save.bocky'then
   begin
    DOSDatum:=FileAge(Dateiname);
    WinDatum:=FileDateToDateTime(DOSDatum);

     if Now - WinDatum =  30 then
      begin
       DeleteFile('bilder\save.bocky');
      end;
     if Now - WinDatum > 30 then
      begin
       DeleteFile('bilder\save.bocky');
      end;


es funzt nich so wie ich es mir erhofft hab...
ich kann es zwar kompelieren, aber sobald ich den button klicke: fehlermeldung.
muss ich das datum erst in nen string umwandeln?