CacheDependency.CacheDependency(String) Constructor

Initializes a new instance of the CacheDependency class that monitors a file or directory for changes.

Namespace: System.Web.Caching
Assembly: System.Web (in system.web.dll)

public:
CacheDependency (
	String^ filename
)
public CacheDependency (
	String filename
)
public function CacheDependency (
	filename : String
)
Not applicable.

Parameters

filename

The path to a file or directory that the cached object is dependent upon. When this resource changes, the cached object becomes obsolete and is removed from the cache.

If the directory or file specified in the filename parameter is not found in the file system, it will be treated as missing. If the directory or file is missing when the object with the dependency is added to the Cache, the cached object will be removed from the Cache when the directory or file is created.

For example, assume that you add an object to the Cache with a dependency on the following file path: c:\stocks\xyz.dat. If that file is not found when the CacheDependency object is created, but is created later, the cached object is removed upon the creation of the xyz.dat file.

The following code example creates an instance of the CacheDependency class with a dependency on an XML file. The System.Web.Caching.Cache.Insert method then adds an item to the Cache that is dependent upon that file.

No code example is currently available or this language may not be supported.
CacheDependency dep = new CacheDependency(get_Server().
    MapPath("isbn.xml"));
get_Cache().Insert("ISBNData", source, dep);

You can also use the following technique to add an item to the Cache with a dependency on a file.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: