Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a WPF application.

In this application I am copying files synchronously as follows.
C#
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.
Posted
Updated 10-Dec-15 22:33pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900