Am saving Webpages from webbrowser control to the directory like below code. Now i want to check all the webpages daily that is modified or not. if it is modified have to update or else leave it.
long size = CalculateDirectorySize(dir, true);
mb = (size) / (1024 * 1024);
var filename1 = webBrowser1.Document.Title;
var path1 = (@"D:\Cache\" + filename1 + ".html");
if (mb != 1)
{
if (File.Exists(path1))
{
MessageBox.Show("Exist");
}
else
{
File.WriteAllText(path1, webBrowser1.Document.Body.Parent.OuterHtml, Encoding.GetEncoding(webBrowser1.Document.Encoding));
MessageBox.Show("Saved");
}
}
else
{
DialogResult dialogResult = MessageBox.Show("Cache Full!! Want to Continue","Confirm", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
DirectoryInfo source = new DirectoryInfo("D:\\Cache");
// Get info of each file into the directory
foreach (FileInfo fi in source.GetFiles())
{
var creationTime = fi.CreationTime;
if (creationTime < (DateTime.Now - new TimeSpan(7, 0, 0, 0)))
{
fi.Delete();
File.WriteAllText(path1, webBrowser1.Document.Body.Parent.OuterHtml, Encoding.GetEncoding(webBrowser1.Document.Encoding));
}
}
MessageBox.Show("Least Recently Used File Deleted And Saved New File");
}
else if (dialogResult == DialogResult.No)
{
MessageBox.Show("Thankyou","Alert");
}
now i want to check (modified since header) of all the webpages stored in D:\Cache Daily. If it is modified haveto update and save the same folder. please any one explain me how to do and give solution.