Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top