Change read-only attribute of a file through Delphi

Posted on 2003-03-12
Medium Priority
Last Modified: 2010-04-04
I have an application that copies Word or Excel files to a 'archive' location.  Once the files are copied there, they can't be changed, so I need to make them read-only using the application.  This is needed so that the files can be viewed by clicking a link in the app, but can't be changed once they are opened.  Not sure if this is even possible, but thought I'd ask.  Thanks
Question by:mrshanes
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

DaFox earned 320 total points
ID: 8119266

FileGetAttr(), FileSetAttr()

FileSetAttr('MyFile.dat', FileGetAttr('MyFile.dat') and faReadOnly);


Expert Comment

ID: 8119340
Is the file opened by another process, while you want to set the attribute???

Author Comment

ID: 8119468
I guess I should have just checked the damn help file!  Oh well, I was in a hurry.  Thanks for the quick reply Markus!

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question