B2017-249 Handle AutoSave feature of MSWord. Handle temporary documents which were not saved when PROMS crashed or was terminated without saving.

This commit is contained in:
Rich
2017-11-06 15:25:09 +00:00
parent bc0504c42e
commit 543a64a4f2
3 changed files with 128 additions and 9 deletions

View File

@@ -50,8 +50,32 @@ namespace Volian.Base.Library
}
public static void RemoveTmpDocs()
{
RemoveTmps("*.doc");
// B2017-249 Recover Temporary File And AutoSave support for MSWord
// Remove temporary Doc Files more than 2 days old so that files with changes can be recoered.
RemoveOldTmps("*.doc");
RemoveOldTmps("*.docx");
RemoveOldTmps("*.rtf");
}
private static void RemoveOldTmps(string extension)
{
string tmpFolder = VlnSettings.TemporaryFolder;
DirectoryInfo di = new DirectoryInfo(tmpFolder);
if (!di.Exists) return;
foreach (FileInfo fi in di.GetFiles(extension))
{
try
{
// delete any docs. If it fails, just go on to the next one becase
// it may be open from another process.
if(fi.LastWriteTimeUtc < DateTime.Now.AddDays(-2.0))
fi.Delete();
}
catch (Exception ex)
{
continue; // if an error, go onto next file.
}
}
}
private static void RemoveTmps(string extension)
{