LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I set a text file's attributes to read-only

I create a text file in my LV application, and write strings to the file. I would like to set the attributes of this new file to read-only within the same application. Is there a way to do this in LV?
Message 1 of 6
(4,730 Views)
Kevin,
Here is a VI that can do that!
Hope this helps. /Mikael
Message 2 of 6
(4,730 Views)
I forgot to mention that this VI was created by Shaun Rumbell. It is easy to use and it can set all the file attributes in Windows! /Mikael
0 Kudos
Message 6 of 6
(4,730 Views)
Hi Kevin,
In File I/O -> Advanced File function you have Access Rights.VI. You have to pass the rights via first 8 bits of input value. They use UNIX format for file attributes (user/group/others). In windows, use just bit 7 for user WRITE - set this to 0 and that means Read Only. I don't know if you can find this VI in LV different from 6.
Another way to do it is to use a Shell Exec.VI with a shell command - in windows will be ATTRIB +R .
You can find details in LV Help(Setting Permissions) and MS-DOS Prompt (ATTRIB /?)
Message 3 of 6
(4,730 Views)
Thanks, that's exactly what I was looking for. I fumbled with the Access Rights.VI before, but I did not know the bit pattern for the input value. You hit the nail right on the head.
0 Kudos
Message 5 of 6
(4,730 Views)
You can use the "Access Rights" function in File I/O>>Advanced File Functions. Wire a numeric with a decimal value of 292 to the "New Permissions" input and the path to the "Path" input. This will set the file to read-only. Wire a decimal value if 438 to make it read/write.

Hope this helps

Brian
0 Kudos
Message 4 of 6
(4,730 Views)