I'm creating a Store app using C# and XAML. I wanted to show the user the progress of file operations such as file copy. The API I'm using is StorageFile.CopyAsync.

It returns a task which is await-able. So I can tell my app to wait for the operation to finish. But if the file is too large I won't be able to tell how much of it, the app has copied.

有帮助吗?

解决方案

Since CopyAsync returns IAsyncOperation<StorageFile> instead of IAsyncOperationWithProgress<StorageFile>, you're out of luck with this API. I don't think there's any built in API for copying that would implement progress reporting (Stream.CopyAsync doesn't implement it either).

You could always implement your own version which copies bytes from one stream to another in chunks and reports progress while doing it. It might be less performant than the built in APIs, though.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top