/// <summary>
/// Archives the exception report.
/// The name of the PDF file is modified to make it easier to identify.
/// </summary>
/// <param name="pdfFile">The PDF file.</param>
/// <param name="archiveDirectory">The archive directory.</param>
public static void ArchiveException(FileInfo pdfFile, string archiveDirectory)
{
// Create a new subdirectory in the archive directory
// This is based on the date of the report being archived
DirectoryInfo di = new DirectoryInfo(archiveDirectory);
string archiveFileName = pdfFile.Name;
string newSubFolder = ParseFolderName(archiveFileName);
try
{
di.CreateSubdirectory(newSubFolder);
}
catch (Exception ex)
{
// The folder already exists so don't create it
}
// Create destination path
// Insert _EXCEPT into file name
// This will make it easier to identify as an exception in the archive folder
string destFileName = archiveFileName.Insert(archiveFileName.IndexOf("."), "_EXCEPT");
string destFullPath = archiveDirectory + "\\" + newSubFolder + "\\" + destFileName;
// Move the file to the archive directory
try
{
pdfFile.MoveTo(destFullPath);
}
catch (Exception ex)
{
}
}