![]() Example |
![]() ![]() ![]() |
acFileStorage component.
|
property Files: TStoredFiles; { Successor of TList. Contains the list of TStoredFile objects }
|
The Files property is the List, which contains all currently stored files. Every item of this list is the file uploaded onto your form at design-time. All files in this list are TStoredFile objects.
|
|
If you would like to access stored file at run-time directly from memory you may use following example:
|
|
var
|
StoredFile: TStoredFile;
|
DataStream: TMemoryStream;
|
begin
|
StoredFile := FileStorage1.Files[1];
|
DataStream := StoredFile.Data; // Data: TMemoryStream
|
begin
|
TStoredFile(acFileStorage1.Files[0]).Data.Position := 1; // Since Data is the stream we must reset its position
|
Memo1.Lines.LoadFromStream(TStoredFile(acFileStorage1.Files[0]).Data);
|
end;
|
procedure TForm1.Button1Click(Sender: TObject);
|
var
|
StoredFile: TStoredFile;
|
St: String;
|
begin
|
StoredFile := acFileStorage1.Files[0]; // first file from FileStorage
|
|
SetLength(St, StoredFile.Data.Size); // set the length of string (StoredFile.Data is the TMemoryStream)
|
Move(StoredFile.Data.Memory^, St[1], StoredFile.Data.Size);
|
|
// and finally we can put the retreived string to Memo control
|
Memo1.Text := St;
|
end;
|
Count and DataSize properties;
|
Extract method.
|