private void RemoveLocalFiles()
{
if (DeleteLocalFiles)
{
var matchingFiles = Directory.EnumerateFiles(LocalDirectory, FileNamePattern);
var filePaths = matchingFiles as string[] ?? matchingFiles.ToArray();
if (filePaths.Any())
{
foreach (var filePath in filePaths)
{
try
{
File.Delete(filePath);
}
catch (Exception e)
{
//catch anything and silently ignore on purpose
//add some debug info in case some issues need to be investigated
if (Logger.IsDebugEnabled)
{
Logger.Debug(e, "Exception encountered while trying to delete file ({0}) :{1}", filePath,
e.Message);
}
}
}
}
}
}
#endregion