CacheDependency Constructor (String)
Initializes a new instance of the CacheDependency class that monitors a file or directory for changes.
Assembly: System.Web (in System.Web.dll)
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.
CacheDependency dep = new CacheDependency(Server.MapPath("isbn.xml")); 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.
Available since 1.1