I have created a WPF application.
In this application I am copying files synchronously as follows.
using (FileStream SourceStream = File.Open(sourceFilePath, FileMode.Open))
{
using (FileStream DestinationStream = File.Create(destinationFilePath))
{
await SourceStream.CopyToAsync(DestinationStream);
}
}
But after successful asynchronous file copy my destination file properties which are
CreationTime,LastAccessTime, LastWriteTime, Owner, computer etc. are not matching with source file properties.
This is all happening because
SourceStream.CopyToAsync() method is writing file as stream to the destination.
I can copy files using the
FileSystem.CopyFile()/FileSystem.CopyDirectory() which can give me the same properties of the source file to the destination file, But here the problem is UI will be blocked till the completion of all files copy.
How can I copy files asynchronously along with both source and destination file properties are same.