The primary reason for making a file read only is to prevent it from being accidentally modified. This could apply to end-user license agreements, readme files, and other documents that the user might open with a text editor such as Word.
In this recipe, we'll install a text file and then set its Read-only flag.
Set the ReadOnly
attribute on a File
element to prevent it from being accidentally modified with the following steps:
Add a
File
element withinComponent
to install a file calledSample.txt
:<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> <Component Id="cmpSampleTXT" Guid="{44BB2441-F98C-41F9-A1FE-EB732B626CF4}"> <File Source="Sample.txt" /> </Component> </ComponentGroup>
Add the ReadOnly attribute to the
File
element to mark that file as read only:<File Source...