LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deny delete file attribute

Hi,

I have a small application where some data are being stored to a txt file. What I want to do is the user to be able to open or copy the file with the results but not being able to delete the file from the hard disk.

Is there any way of setting this attribute in my application when the file is initially created?

 

Thank you.

 

Achille 

0 Kudos
Message 1 of 4
(2,944 Views)

I would recommend using the 'Set Permissions' fuction under:

Programming >> File I/O >> Advanced File Function.

 

Input the path for the file of interest.

Then for the input 'Permissions', look at the LabVIEW help for this function.

It takes a 9 bit input to select : full access, read-only, no access.

 

For Windows, I think all you can modify is bit 7, write-access (which would also not allow you to delete).

If you wire 200 to Permissions, it is the equivalent (in binary) to 10000000.

This will make the file read-only.

 

permissions.PNG

Cory K
0 Kudos
Message 2 of 4
(2,920 Views)

Dear Cory,

Thank you for your reply. I have tried your suggestion but although the file becomes read-only I am still able to delete it.

I am trying to figure out a way but I haven't find anything yet.

Any other suggestion?

 

Thank you.

 

Achille 

 

0 Kudos
Message 3 of 4
(2,906 Views)

To set a file to read only you need to wire decimal 256 (octal 400, binary 100000000) to the permissions input.

 

To set the permissions in more details you need some other tools or access the windows API.

 

Daniel

 

0 Kudos
Message 4 of 4
(2,898 Views)