using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Web.Caching;
using System.IO;

public partial class test_cache_fichier_dep : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
		string contenu;
		if (Cache["nouvelles"] == null)
		{
			// lecture du fichier
			string chemin = @"c:\temp\nouvelles.txt";
			FileStream f;
			f = new FileStream(chemin, FileMode.Open, FileAccess.Read);
			TextReader reader = new StreamReader(f);
			contenu = reader.ReadToEnd();
			reader.Close();
			f.Close();

			// mlse en cache
			CacheDependency dep = new CacheDependency(chemin);
			Cache.Add("nouvelles", contenu, dep, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
		}
		else
			contenu = Cache["nouvelles"] as string;

		Label1.Text = contenu;
    }
}
