Autor Beitrag
bingo72
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39



BeitragVerfasst: Di 21.11.06 21:06 
Hallo Experten!!

Ich versuche eine bestehende Datei zu löschen mittels DeleteFile...
Doch nachher ist die Datei noch immer vorhanden. Es gibt keine Fehlermeldungen oder sonstige Anomalien??!!

Zuvor habe ich die Datei umbenannt....hat funktioniert...falls das von Bedeutung ist!!??
Hab was gelesen von Datei freigeben oder so?? Wie funktioniert das?? Oder wie lösch ich sonst die Datei??

LG
Thomas
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 21.11.06 21:15 
Wenn DeleteFile eine Function ist (:gruebel:), kannst du doch einfach den Rückgabewert prüfen. Ansonsten prüfe einfach, ob du den Dateipfad richtig übergibt und das Verzeichnis nicht anderweitig gesperrt ist.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
bingo72 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39



BeitragVerfasst: Mi 22.11.06 08:08 
user profile iconMarco D. hat folgendes geschrieben:
Wenn DeleteFile eine Function ist (:gruebel:), kannst du doch einfach den Rückgabewert prüfen. Ansonsten prüfe einfach, ob du den Dateipfad richtig übergibt und das Verzeichnis nicht anderweitig gesperrt ist.


Hallo Marco!!

Der Rückgabewert ist 32...also Datei wird noch von einem anderen Prozeß benutzt...

Habe auch schon mit

ausblenden Delphi-Quelltext
1:
SetFileAttributes(TEMP_VIDEO_LARGE, FILE_ATTRIBUTE_NORMAL);					


versucht Zugriff auf die Datei zu erlangen...aber ohne Erfolg!!
Was kann ich tun??

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt
Silas
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 478

Windows XP Home
Delphi 2005, RAD Studio 2007, MASM32, FASM, SharpDevelop 3.0
BeitragVerfasst: Mi 22.11.06 08:26 
Moin!

Hast du die Datei vorher in deinem Programm geöffnet(Also per AssignFile, nicht per savetofile oder loadfromfile)?

_________________
Religionskriege sind nur Streitigkeiten darüber, wer den cooleren imaginären Freund hat ;-)
bingo72 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39



BeitragVerfasst: Mi 22.11.06 08:36 
user profile iconSilas hat folgendes geschrieben:
Moin!

Hast du die Datei vorher in deinem Programm geöffnet(Also per AssignFile, nicht per savetofile oder loadfromfile)?


Hallo Silas!!

Also die Datei wird von DirectX erzeugt...ist eine VideoDatei (WMV)...ich will die Datei aber erst löschen, wenn die Aufnahme schon lange beendet ist und alle DirectX-Filter auf nil gesetzt sind...nämlich in der FormClose-Prozedure...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TfmMain.FormDestroy(Sender: TObject);
var
  str : String;
begin
  SetToNil();
  CoUninitialize();
  if (FileExists(TEMP_VIDEO_LARGE) AND FileExists(TEMP_VIDEO_SMALL)) then begin
    if (not(DeleteFile(TEMP_VIDEO_LARGE))) then
      str := IntToStr(GetLastError);

    //DeleteFile(TEMP_VIDEO_SMALL);
  end;
end;


Moderiert von user profile iconTino: Delphi-Tags hinzugefügt
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Mi 22.11.06 08:45 
bau das ganze mal in die

ausblenden Delphi-Quelltext
1:
 OnFormClose					


Was steht in TEMP_VIDEO_LARGE drin?
Die Datei mit Pfadangabe?

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
bingo72 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39



BeitragVerfasst: Mi 22.11.06 09:02 
Problem gelöst!!

Ursache war ein DirectX-internes Problem...habe zwar die Filter abgebaut, aber dennoch hat er nachwievor auf die Datei geschrieben!!

Danke für die Ideen!! :wink:

LG
Thomas