Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prevent file from being deleted

Status
Not open for further replies.

SykoStokkrTim

Programmer
Jul 19, 2002
20
US
How would one go about making a file that can not be deleted?
 
Make it read-only.
Look up the SetAttr statement.
e.g.
SetAttr FileName, Attributes

Attributes are one or more of:
vbNormal, vbReadOnly, vbHidden, vbSystem & vbArchive

Combine them by ORing them together.
e.g. To make C:\Autoexec.bat read-only & hidden
SetAttr "C:\Autoexec.bat", vbReadOnly Or vbHidden
 
Right-click the file(s) in Windows Explorer and select Properties. Place a tick in the read-only checkbox.

The attribute can always be reset again though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top