Implement MoveFileOrFolderJob.cs

This commit is contained in:
Glax 2025-03-08 18:35:41 +01:00
parent 313225a1a1
commit 832ddf1442

View File

@ -8,6 +8,33 @@ public class MoveFileOrFolderJob(string fromLocation, string toLocation, string?
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
{
throw new NotImplementedException();
try
{
FileInfo fi = new FileInfo(FromLocation);
if (!fi.Exists)
return [];
if (File.Exists(ToLocation))//Do not override existing
return [];
if(fi.Attributes.HasFlag(FileAttributes.Directory))
MoveDirectory(fi, ToLocation);
else
MoveFile(fi, ToLocation);
}
catch (Exception e)
{
}
return [];
}
private void MoveDirectory(FileInfo from, string toLocation)
{
Directory.Move(from.FullName, toLocation);
}
private void MoveFile(FileInfo from, string toLocation)
{
File.Move(from.FullName, toLocation);
}
}