AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

read from multiple Files

Ein Thema von mohfa · begonnen am 25. Mär 2009 · letzter Beitrag vom 26. Mär 2009
 
Muetze1
(Gast)

n/a Beiträge
 
#5

Re: read from multiple Files

  Alt 26. Mär 2009, 07:31
Hi!

In your Load function, you create a new stringlist. Then you just add one filename to this stringlist. After this, you iterate through all items of the stringlist (everytime just one) and you are wondering why it is still just one entry?

Delphi-Quellcode:
Procedure Load(const AFilenames: TStrings);
var
  MS : TMemoryStream;
  FS : TFileStream;
  i:integer;
begin
  MS := TMemoryStream.Create;
  try
    For i:=0 to AFilenames.Count-1 do
    begin
      if FileExists(AFilenames[i]) then
      begin
        FS := TFileStream.Create(MyStringList[i], fmOpenRead or fmShareDenyNone);
        try
          MS.CopyFrom(FS, FS.Size);
        finally
          FS.Free;
        end;
      end;
  finally
      // All the MS contents will be saved to Res.txt as an example
    MS.SaveToFile('Res.txt');
    MS.Free;
  end;
end;
Delphi-Quellcode:
// as an example how to use it
procedure TForm1.Button1Click(Sender: TObject);
var
  i:integer;
begin
  {FilesList : is a TListBox
  items[0]:=c:\001.txt
  items[1]:=c:\002.txt
  .
  .
  .
    }


  Load(FilesList.Items);
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:59 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz