CameraCaptureUI.CaptureFileAsync() is returning a corrupt StorageFile if user selects "Save as a copy" option on the OS dialog

Imtiaz, Maham 0 Reputation points
2023-11-30T16:16:10.9333333+00:00

When using CameraCaptureUI in a UWP app, if cropping is allowed as follows:

CameraCaptureUI captureUI = new CameraCaptureUI();

captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;

captureUI.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);

StorageFile photo = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);

The StorageFile returned from the CaptureFileAsync() call is corrupt when user selects Save as a copy instead of Save after performing the OS Photos dialog popup that is part of the CaptureFileAsync() call. It is 0 bytes in size.

Why is the image coming back corrupt? And is there a way of checking where the user saved the edited copy?

Universal Windows Platform (UWP)
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,349 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
11,199 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.