Code for the file dependency in cache, DOT NET Programming

Show the code for the file dependency in cache?

Partial Class

Default_aspx

Public Sub displayAnnouncement() Dim announcement As String

If Cache("announcement") Is Nothing Then

Dim file As New _ System.IO.StreamReader _

(Server.MapPath("announcement.txt")) announcement = file.ReadToEnd file.Close()

Dim depends As New _ System.Web.Caching.CacheDependency _

(Server.MapPath("announcement.txt")) Cache.Insert("announcement", announcement, depends)

End If

Response.Write(CType(Cache("announcement"), String)) End Sub

Private Sub Page_Init(ByVal sender As Object, ByVal e As

System.EventArgs) Handles Me.Init displayAnnouncement()

The Above given process display Announcement () displays banner text from the Announcement.txt file that is lying in  the application path of the web directory. The Above method first checks whether the Cache object is nothing, if the cache object is nothing then it moves further to load the cache data from the file. When the file data changes the cache object is removed and set to nothing.

Posted Date: 9/22/2012 2:13:20 AM | Location : United States







Related Discussions:- Code for the file dependency in cache, Assignment Help, Ask Question on Code for the file dependency in cache, Get Answer, Expert's Help, Code for the file dependency in cache Discussions

Write discussion on Code for the file dependency in cache
Your posts are moderated
Related Questions
Project Description: We require a Part time or long contract, Programmer/Developer working in Sydney. Task - Write PHP software into asp.net. Develop new software to enhan

ASP.NET/MSSQL/ MVC completing backend solution + integrating with frontend. Project Description: System is used for tracking company's activities through several projects by

Custom Login Page for SharePoint 2013 with Active Directory Project Description: I would like to prepare a webpart or an application for Sharepoint 2013 foundation. The we

Write a XML with database with book details (BOOK ID, Title, Author, subject, published Year, language, vendor, price)

Need to get a windows desktop application developed Project Description: I am looking to obtain a desktop application developed. The desktop application will have the subsequ

What is CLR?  CLR(Common Language Runtime) is the major resource of .Net Framework. It is collection of services such as garbage collector, exception handler, jit compilers etc

Briefly explain the characteristics of reference-type variables that are supported in the C# programming language. The variables that are based on reference types keeps referen

Project Description: I need to unlock software or make a similar kind of software. It is presently installed in my PC and I will provide you installation files if needed. It wil

mailer - mail sender Project Description: I want a mailer: -run on Windows Server 2008 -use how many theard i need -more details speak on private Skills required

Niles Video Inc. wants to create a website for online sales of movies (DVD and videotapes). People will be allowed to register as customers on the website and to update their store