MarcoV
1
Hi all,
Just a small question (I hope). I would like to be able to check from NAV if a certain file is read only or not.
I tried to fix something with a file variable and with the file table. But I can’t figure out to read the attributes of the file.
Any suggestions?
Vorauer
2
Hi Marco,
not sure if this really works but we often use the rename function to check if a file is already completly written. As in
if rename(filename,filename) then
fileispresent := ok;
maybe you can use this also for your problem?
Regards,
Jan
MarcoV
3
Ok, got it…
This is how you do it:
You need the following variables:
- FileSystemObject: Automation - ‘Microsoft Scripting Runtime’.FileSystemObject
- MyFile: Automation - ‘Microsoft Scripting Runtime’.File
- MyAttributes: Integer
IsReadOnly(FileName: Text(250)):Boolean
IF ISCLEAR(FileSystemObject) THEN
CREATE(FileSystemObject);
MyFile := FileSystemObject.GetFile(Filename);
MyAttributes := MyFile.Attributes;
IF (MyAttributes MOD 2 <> 0) THEN
EXIT(TRUE) //Readonly
ELSE
EXIT(FALSE); //Read-write
I found the info here
MarcoV
4
Hi Jan,
Thanks for the input but I wanted to show the readonly attribute in a form. So creating an error was not an option. But I think I found it.
Marco