The application is one thread, the file handling is done by the 
operating system in an other thread.
FreeAndNil releases indded the Class TFileStream but the OS can still 
have a capture on the file.
This will not happen if you use one instance of an attached class 
throughout your application.

Succes, Anthony Vogelaar.

============================================================================
> On Mon, 26 Jan 2009, Dave Coventry wrote:
>
>   
>> Hi AJ.
>>
>> I was under the impression that this:
>>
>>  FS:=TFileStream.Create(fname, fmshareDenyWrite);
>>  Try
>>    FS.ReadBuffer(hdbuffer[0],32);
>>  Finally
>>    FreeAndNil(FS);<-----
>>  end;
>>
>> would free the File Pointer to be used again.
>>     
>
> That is correct.
>
>   
>> Do you suggest that I use another variable when I do it the second time?
>>     
>
> That should absolutely not be necessary.
>
>   
>> Is it possible to specify that the program only uses one thread?
>>     
>
> This is so by default, unless you create threads yourself ?
>
> More likely is simply the fact that the file cannot be locked.
>
> Michael.
> _______________________________________________
> Lazarus mailing list
> Lazarus@lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
>   

_______________________________________________
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to