Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Filestream - Add a File to an other File (https://www.delphipraxis.net/26653-filestream-add-file-other-file.html)

cdkiller 27. Jul 2004 08:38


Filestream - Add a File to an other File
 
hy,

i have the following problems. i have a txt and a dll file.

now i want that the dll file will add at the end of the txt file.
i mean that i want to insert a dll file in a txt file at the end.

i have tried it with a filestream. but it doesnt do it what it should.

can someone post a function ?

thanks...

sakura 27. Jul 2004 08:40

Re: Filestream - Add a File to an other File
 
I got no idea why anyone wants to do, what you want to do, however, you should show us your code and we will be able to help you to fix it ;)

...:cat:...

cdkiller 27. Jul 2004 08:55

Re: Filestream - Add a File to an other File
 
okay,

this is my code:

it should add a dll file to an other file.

Delphi-Quellcode:
var
fs,fs2 : TFileStream;
Buffer: Pointer;
Buffer2: Pointer;
filename: string;
begin
if OpenDialog1.Execute then filename := OpenDialog1.FileName;
fs := TFileStream.Create(filename, fmOpenReadWrite);
fs.ReadBuffer(Buffer^,Sizeof(Buffer^));
fs.Seek(0,soFromEnd);

fs2 := TFilestream.Create('sf_wrapper.dll', fmOpenRead);
fs2.ReadBuffer(Buffer2^,Sizeof(Buffer2^));
fs.WriteBuffer(Buffer2^,Sizeof(Buffer2^));

fs.Free;
fs2.Free;
where is the error or can you fix it ?

[edit=sakura] No pushing within 48 hours :!: Mfg, sakura[/edit]

Steve 27. Jul 2004 09:52

Re: Filestream - Add a File to an other File
 
Althoug I don't know for what reason you might need this, here's my answer :zwinker:
Zitat:

Zitat von cdkiller
Delphi-Quellcode:
fs2.ReadBuffer(Buffer2^,Sizeof(Buffer2^));
where is the error or can you fix it ?

What do you expect "Sizeof(Buffer2^)" to be? you should use "FS2.Size" instead of it... I didn't check if this works cause I'd use the function "CopyFrom":
Delphi-Quellcode:
var
  fs,fs2  : TFileStream;
begin
  if OpenDialog1.Execute then
  try
    fs      := TFileStream.Create(OpenDialog1.FileName, fmOpenReadWrite);
    fs2      := TFilestream.Create('myDLL.dll',         fmOpenRead);
    fs.Seek (fs.Size,soFromBeginning);
    fs2.Seek(0,     soFromBeginning);
    fs.CopyFrom(fs2,fs2.Size);
  finally
    fs.Free;
    fs2.Free;
  end;
end;
(By the way: there were a few 'errors' in your code :wink:, e.g. you don't need to read sth. from FS.)

Greetz
Stephan

Luckie 27. Jul 2004 10:35

Re: Filestream - Add a File to an other File
 
Look for my class Hier im Forum suchenTArchive. That's all you need. My class will do all the rest for you. ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:24 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz