APGen Documentation Previous Topic: CachedFile.MonitoringFileChanges Next Topic: CachedFile.Write() Parent Topic: CachedFile Object    CachedFile Object
CachedFile.Open()
See Also:

Opens a file and holds its file handle, or holds its contents in memory.

Syntax

VBScript:

cachedFile.Open sPath [, bMapPath ] [, bMonitorFileChanges ]

JScript:

cachedFile.Open( sPath [, bMapPath ] [, bMonitorFileChanges ] );

Object

cachedFile A CachedFile object.

Parameters

sPath The string path of the file to be cached. 

If bMapPath is True, this path is resolved using Server.MapPath().  If bMapPath is False, this should be a complete path.
bMapPath Optional Boolean parameter - the default is True.  If True, Server.MapPath() is called on sPath to resolve the path.
bMonitorFileChanges Optional Boolean parameter - the default is True.  If True, the cached contents are updated whenever the file on disk changes.  If False, a snapshot of the file is cached.

Monitoring for file changes is quite efficient in Windows 2000, but has a performance penalty under Windows NT 4.  For more information see ASPCache.WriteFile().

Notes

ASPCache.WriteFile() calls CachedFile.Open() when creating a new CachedFile object, which is why the parameters are similar.

If the file described by sPath cannot be found, an error is raised.

Open() is not a thread-safe method, so it should not be called on a CachedFile object that is stored in an ASPCache.  If you need to re-open a CachedFile object, remove it from the cache before re-opening it:

' Re-open a CachedFile object stored in the Cache

Dim sPath, cf

If Cache.Exists(sPath) Then

     ' Retrieve a CachedFile object from the Cache
     Set cf = Cache(sPath)

     ' Remove it from the Cache
     Cache.Remove sPath

     ' Re-open the CachedFile object
     cf.Open sPath

     ' Insert the CachedFile back in the Cache
     Cache(sPath) = cf

End If