Autor Beitrag
gerd8888
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205
Erhaltene Danke: 3

Win7
Delphi 10.1 Starter (kostenlos) Lazarus
BeitragVerfasst: Sa 28.04.12 01:07 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
if not fileexists(extractfilepath(ParamStr(0))+dateiname) then
  FileCreate(ExtractFilePath(ParamStr(0))+dateiname);

...

fs:=TFileStream.Create(Filename,fmopenreadwrite);


Dann mit der Fehlermeldung EFOpenError
Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.

Ich wuesste nicht, von welchem Prozess das verwendet wird. Habe ich das Filecreate vielleicht nicht richtig erstellt??

Wenn ich anschliessend das Programm neu starte, ist die Fehlermeldung weg.
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Sa 28.04.12 07:51 
Du blockierst selbst mit Deinem FileCreate
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
const
 C_BUFF='Blub..';
var
  fs:TfileStream;
  fn:String;

  Function CreateIfNotExits(const fn:String):Word;
    begin
    if not FileExists(fn) then Result := fmCreate else Result := 0;
    end;

begin
  fn := 'C:\temp\test.xxx';
  fs := TfileStream.Create(fn,CreateIfNotExits(fn) or fmopenWrite or fmShareExclusive);
  fs.Position:=fs.Size;
  fs.Write(C_BUFF[1],Length(C_BUFF)*SizeOf(Char));
  fs.Free;
end;

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS

Für diesen Beitrag haben gedankt: gerd8888
gerd8888 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205
Erhaltene Danke: 3

Win7
Delphi 10.1 Starter (kostenlos) Lazarus
BeitragVerfasst: Sa 28.04.12 09:25 
mit filestream eine datei erzeugen.
ja, dann kommt keine fehlermeldung mehr.
allerdings frage ich mich, warum ich mit filecreate etwas blockiere.
ich habe mir das so vorgestellt. er erstellt mit filecreate eine datei und schliesst sie.
aber offensichtlich ging das nicht.
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Sa 28.04.12 12:22 
Schau Dir mal an was FileCreate als Rückgabewert liefert ...

_________________
Das Problem liegt üblicherweise zwischen den Ohren H₂♂
DRY DRY KISS