AdvMemo lock file

Good morinig to all,

j have this strange situation with an AdvMemo component.



In a form drop a TAdvMemo component and in form create try:

(Memo1 is the TAdvMemo name)



Memo1.Lines.LoadFromfile(FileName)



FileName is a text file and now all the lines are loaded into the memo.



Now we can work into the memo without modify the original one, but open the explorer find the file according to FileName and try to delete it.

The file is locked.



Ofcourse, j don't need to delete it, but j need to store it in a table and, in delphi XE 2 j'm not able to perform this line



(Table1.FieldByName('OriginalFile') as TBlobField).LoadFromFile(FileName);



because filename was loaded into memo and j get the exception "the file is in use in other proces"



The reason of blob is due the fact that sometime the file is .txt and sometime is .pdf or xls/xlsx



There's a way to unlock the file after loaded into memo ???



Thank's



Daniele

I have tested this here with a default TAdvMemo on the form and the code:


procedure TForm1.FormCreate(Sender: TObject);
begin
  advmemo1.Lines.LoadFromFile('c:\temp\test.txt');
end;

and I can delete the file test.txt while the app is running after loading this file in TAdvMemo. There is also not any code in TAdvMemo itself that would lock this file. This basically works in TAdvMemo the same as loading a file in a TStringList from Delphi. I suspect it is something else that is causing this.

Hi Bruno,

j'll check on what cause this strange situation.



Thank's again



Daniele