Check File Length
This commit is contained in:
parent
b418903e99
commit
2d08e4d8e9
18
FileCopy.cs
18
FileCopy.cs
@ -28,9 +28,25 @@ public class FileCopy
|
||||
foreach (var file in sourceDir.GetFiles())
|
||||
{
|
||||
string destinationFile = Path.Combine(desDir.FullName, file.Name);
|
||||
if (File.Exists(destinationFile))
|
||||
{
|
||||
var desFileInfo = new FileInfo(destinationFile);
|
||||
if (desFileInfo.Length != file.Length)
|
||||
{
|
||||
Console.WriteLine($"Renew {file} --> {destinationFile}");
|
||||
file.CopyTo(destinationFile, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Same {file} --> {destinationFile}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"NewFile {file} --> {destinationFile}");
|
||||
file.CopyTo(destinationFile, true);
|
||||
}
|
||||
|
||||
Console.WriteLine($"{file} CopyTo--> {destinationFile}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -33,7 +33,7 @@ managementEventWatcher.EventArrived += (s, e) =>
|
||||
Directory.CreateDirectory(dPath);
|
||||
}
|
||||
FileCopy.Copy(driveName, dPath);
|
||||
Console.WriteLine("Scaned and waiting ----------------------");
|
||||
Console.WriteLine("\n--------------Scaned and waiting--------------\n");
|
||||
};
|
||||
|
||||
managementEventWatcher.Start();
|
||||
|
Loading…
Reference in New Issue
Block a user