Zitat von
alzaimar:
Btw: In your code sample, you don't have to set any of the 'Size' or 'Position' properties. This is done by the constructor and the CopyFrom method, by setting the Size-parameter to 0.
Delphi-Quellcode:
Procedure Load(const AFilename: String);
var
MS : TMemoryStream;
FS : TFileStream;
begin
if FileExists(AFilename) then
begin
MS := TMemoryStream.Create;
try
FS := TFileStream.Create(AFilename, fmOpenRead or fmShareDenyNone);
try
//FS.Position := 0;
//MS.Position := 0;
MS.CopyFrom(FS, FS.Size);
finally
FS.Free;
end;
finally
MS.Free;
end;
end;
end;
Zitat:
Delphi-Quellcode:
MyStringList:=TStringList.Create;
// string list contains no files. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
For i:=0 to MyStringList.count-1 do
if FileExists(MyStringList[i]) then
Delphi-Quellcode:
MS := TMemoryStream.Create;
try
For i:=0 to MyStringList.Count-1 do
if FileExists(MyStringList[i]) then
begin
FS := TFileStream.Create(MyStringList[i], fmOpenRead or fmShareDenyNone);
try
MS.CopyFrom(FS, FS.Size);
finally
FS.Free;
end;
end;
...
finally
MS.Free;
end;