Summer.Batch.Extra.FtpSupport.FtpGetTasklet.RemoveLocalFiles C# (CSharp) Method

RemoveLocalFiles() private method

Remove local files prior to downloading fresh ones
private RemoveLocalFiles ( ) : void
return void
        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