[fpc-pascal] Assigning a file

Michalis Kamburelis michalis at camelot.homedns.org
Sat Oct 15 03:14:16 CEST 2005


L505 wrote:
> Does assigning and then reseting a file require write permissions on Linux and Windows? I'm
> getting ELnOutError access Denied when I try to assign a file. It works fine if I give the
> file write permissions
> 
> program Project1;
> {$mode objfpc}{$H+}
> uses
>   SysUtils;
> var
>   FileName: string;
>   TheFile: file of char;
> begin
>   FileName:= 'test.txt' ;   //a read only file in the directory
>   assign(TheFile, filename);
>   reset(TheFile);
>   readln;
> end.
> 
> 
> An unhandled exception occurred at $0805B42D : EInOutError : Access denied $0805B42D
> $0804DCDE $0804842C
> 

Do
   FileMode := fmOpenRead;
if you want read-only access. Default FileMode is fmOpenReadWrite, as 
far as I remember.

Michalis



More information about the fpc-pascal mailing list