将网页浏览器控件中的网页保存到下面的代码目录中。现在我想检查每天修改或未修改的所有网页。如果它被修改必须更新或者保留它。
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");
}
现在我想检查(自标题修改后)存储在D:\ Cache Daily中的所有网页。如果修改了必须更新并保存相同的文件夹。 请任何人解释我该怎么做并给出解决方案。