mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-14 04:13:18 +02:00
Implement MoveFileOrFolderJob.cs
This commit is contained in:
parent
313225a1a1
commit
832ddf1442
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user