Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Fr 11.04.03 20:45 
Hallo,

Kann man mit TFileStrem oder anders eine Byte ab Position so und so 512 Bytes einfügen wobei die Datei um 512 Bytes größer wird?

Oder geht das nicht?

Danke..
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: So 13.04.03 12:06 
Hallo Biachiv!

Ich nehme an du suchst nach einer Funtion Insert. Doch diese gibt es leider nicht bei FileStreams.
Das heisst du musst der restliche Teil in einen neuen Stream laden und diesen dann wieder an den ursprünglichen Stream anhängen, nachdem du die 512 Bytes angefügt hast.
Code folgt später!

Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: So 13.04.03 13:51 
Der Beispielcode wie versprochen:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure Insert(const Stream, InsertStream: TStream; const Position: LongInt);
var
  MemoryStream: TMemoryStream;
begin
  if Position >= Stream.Size then begin
    Stream.Position := Stream.Size;
    Stream.CopyFrom(InsertStream, 0);
  end
  else begin
    Stream.Position := Position;
    MemoryStream := TMemoryStream.Create;
    try
      MemoryStream.CopyFrom(Stream, Stream.Size - Stream.Position);
      Stream.Position := Position;
      Stream.CopyFrom(InsertStream, 0);
      Stream.CopyFrom(MemoryStream, 0);
    finally
      MemoryStream.Free;
    end;
  end;
end;
Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Fr 18.04.03 08:53 
Hallo wulfskin,

Ja das ist das was ich suche nur kann ich den Code nicht compilen.
Ist ein functions fehler.

Als Anwendungsbeispiel habe ich
insert(file1, file2, 5000); //genommen
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Fr 18.04.03 18:06 
Biarchiv hat folgendes geschrieben:
Hallo wulfskin,

Ja das ist das was ich suche nur kann ich den Code nicht compilen.
Ist ein functions fehler.

Als Anwendungsbeispiel habe ich
insert(file1, file2, 5000); //genommen
Ähhhmmm ja, und? Welche Fehler kommen?
Bei mir klappt es wunderbar. Irgendwas machst du falsch. Poste bitte etwas Code!

Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: So 20.04.03 11:23 
Hallo,

Doch sie geht erst ab Delphi6.

Bei meinen Dephi5 leider nicht.
"TFileStream und String incomportibel"