Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-10

Re: Assigning a file

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michalis Kamburelis
to L505: Does assigning and then reseting a file require write permissions on Linux and Windows?…
L505 wrote 22 lines
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

L505

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

L505
to Michalis Kamburelis: Do FileMode := fmOpenRead; if you want read-only access. Default FileMode is…
Show quoted text 9 lines
> An unhandled exception occurred at $0805B42D : EInOutError : Access denied $0805B42D > $0804DCDE $0804842C > FileMode := fmOpenRead; if you want read-only access. Default FileMode is fmOpenReadWrite, as far as I remember. Michalis

Thank you. As it states in the documentation, reset depends on filemode! Now I know to set it beforehand :)