I'm trying to use TMSFMXDirectoryTreeView1.LoadFromStream and get a tstream error exception "TStream.Seek not implemented". I'm using Tokyo 10.2 and the latest version of TMS FMX UI.
The reason I'm doing this is because I'm downloading a directory from a remote server. I'm adding string values to the stream that contain file information such as file name, file date, etc.
Any assistance would be appreciated.
Can you post your code that is creating the stream and loading it into the TTMSFMXDirectoryTreeView?
very basic, trying to test to get this to work
Var
AStream: TStream; //global
//loads file info from remote server directory
//for this test just loading file name but other attributes are available
TMainConnect.LoadDirectory;
begin
while not ServerDirectory.Eof do
begin
AStream.Write(ServerDirectory.Filename[1], ByteLength(ServerDirectory.Filename));
ServerDirectory.Next
end
end;
TMainConnect.ShowDirectory;
begin
try
AStream := TStream.Create;
LoadDirectory;
TMSFMXDirectoryTreeView1.LoadFromStream(AStream);
finally
AStream.Free
end
end;
Can you set AStream.Position := 0 before loading the stream in the directory treeview?
Still same error. I have this code in my form create event
TMSFMXDirectoryTreeView1.Interaction.ColumnAutoSizeOnDblClick := True;
TMSFMXDirectoryTreeView1.Interaction.ColumnSizing := True;
TMSFMXDirectoryTreeView1.AddColumn(tvckName);
TMSFMXDirectoryTreeView1.AddColumn(tvckDisplayName);
TMSFMXDirectoryTreeView1.AddColumn(tvckCreationDate).Visible := False;
I tried commenting out the last 2 lines but that still did not work
Hi,
Can you create a sample that demonstrates this, we have investigated this here but are not able to reproduce this issue.
making some progress, changed to a TMemoryStream and no longer getting an error but the directory is not populating. is there a format I should use for the stream ? How can I send a screen print?
thank you
SaveToStream and LoadFromStream works with a specific format, compatible with TTreeView. You should first use a SaveToFile to a txt file to learn about the format.
Please let me know if there is a way to send a screenprint. I did the following
1)using the demo used savetofile with AtextOnly = true
2) used the following logic to test loading the file to a stream and the stream into the treeview and nothing appears
var
FileStream : TFileStream;
Bytes: TBytes;
Filename : string;
begin
Filename := 'C:\Finale\Edata\DirView';
FileStream:= TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
if FileStream.Size>0 then
begin
SetLength(Bytes, FileStream.Size);
FileStream.Read(Bytes[0], FileStream.Size);
end;
showmessage(TEncoding.ASCII.GetString(Bytes)); //displays the contents of the file correctly
TMSFMXDirectoryTreeView1.LoadFromStream(FileStream); //nothing loads into the directory
finally
FileStream.Free;
end;
end;
Can you set FileStream.Position := 0 before loading the stream?
Making progress. The name appears but the other fields do not. Here is my code to setup the directory tree:
TMSFMXDirectoryTreeView1.Interaction.ColumnAutoSizeOnDblClick := True;
TMSFMXDirectoryTreeView1.Interaction.ColumnSizing := True;
TMSFMXDirectoryTreeView1.AddColumn(tvckName);
TMSFMXDirectoryTreeView1.AddColumn(tvckDisplayName);
TMSFMXDirectoryTreeView1.AddColumn(tvckCreationDate).Visible := true;
TMSFMXDirectoryTreeView1.AddColumn(tvckModificationDate).Visible := true;
TMSFMXDirectoryTreeView1.AddColumn(tvckCustom).Text := 'Extension';
TMSFMXDirectoryTreeView1.AddColumn(tvckFreeSpaceAndTotalSize);
Can you send us a sample that reproduces this issue?
what is the best way for me to send an attachment?