Removed HelperEAFProgramData-MoveFiles
This commit is contained in:
@ -1,37 +0,0 @@
|
||||
using File_Watcher.Models;
|
||||
|
||||
namespace File_Watcher.Helpers;
|
||||
|
||||
internal static partial class HelperEAFProgramData
|
||||
{
|
||||
|
||||
internal static bool MoveFiles(AppSettings appSettings, ILogger<Worker> logger)
|
||||
{
|
||||
string checkFile;
|
||||
string checkDirectory;
|
||||
string source = Path.GetFullPath(appSettings.EAFProgramDataConfiguration.Source);
|
||||
string[] files = Directory.GetFiles(source, "*", SearchOption.AllDirectories);
|
||||
logger.LogInformation("After {MillisecondsDelay} with search pattern '{SearchPattern}' found {files}", appSettings.MillisecondsDelay, appSettings.EAFLogConfiguration.SearchPattern, files.Length);
|
||||
foreach (string file in files)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
checkFile = file.Replace(source, appSettings.EAFProgramDataConfiguration.Destination);
|
||||
if (checkFile == file)
|
||||
throw new NotSupportedException("Replace failed!");
|
||||
checkDirectory = Path.GetDirectoryName(checkFile) ?? throw new NotSupportedException();
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(checkDirectory))
|
||||
_ = Directory.CreateDirectory(checkDirectory);
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Move(file, checkFile);
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ logger.LogInformation(ex, "Inner loop error!"); }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user