CFLib.org – Common Function Library Project

SetReadOnly(sFilePath, bReadOnly)

Last updated September 27, 2001

Version: 1 | Requires: ColdFusion 5 | Library: FileSysLib

 
Rated 0 time(s). Average Rating: 0

Description:
Convenience function to set/clear the ReadOnly attribute for the specified file.

Return Values:
Returns a Boolean value indicating whether the attribute was set.

Example:

view plain print about
<CFSET x = SetReadOnly("c:\myfile.txt""Yes")>

<CFOUTPUT>
Was the attribute set? #YesNoFormat(x)#
</CFOUTPUT>

Parameters:

Name Description Required
sFilePath Absolute or relative path to the specified file. Yes
bReadOnly Boolean value indicating whether the attribute should be read only (Yes) or (No). Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Convenience function to set/clear the ReadOnly attribute for the specified file.
 * Uses COM. This is a Windows only funciton. Requires CFOBJECT be enabled in the CF Administrator. This function depends on the SetFileAttribute() function in this library. See the SetFileAttribute() function for details.
 * 
 * @param sFilePath      Absolute or relative path to the specified file. 
 * @param bReadOnly      Boolean value indicating whether the attribute should be read only (Yes) or  (No). 
 * @return Returns a Boolean value indicating whether the attribute was set. 
 * @author Nate Weiss (nate@nateweiss.com) 
 * @version 1, September 27, 2001 
 */

function SetReadOnly(sFilePath, bReadOnly) {
   return setFileAttribute(sFilePath, "ReadOnly", bReadOnly);
 };
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson