Search code examples
vb.netimagewindows-store-apps

CameraCaptureUI Save picture at specified location


I am using CameraCaptureUI API to take a picture on a windows tablet. I can take the picture, but I have no idea where it is saved or how to change it's save folder.

I have tried doing the following code to save it in the picture library without success :
Dim fileCopy As StorageFile = Await file.CopyAsync(KnownFolders.PicturesLibrary, "MyNicePhoto.bmp", NameCollisionOption.ReplaceExisting)

Here is the code I use to take the picture (taken from a CameraCaptureUI Sample)

Private appSettings As Windows.Foundation.Collections.IPropertySet
Private Const photoKey As String = "capturedPhoto" 

 Try
    ' Using Windows.Media.Capture.CameraCaptureUI API to capture a photo
    Dim dialog As New CameraCaptureUI()
    Dim aspectRatio As New Size(16, 9)
    dialog.PhotoSettings.CroppedAspectRatio = aspectRatio

    Dim file As StorageFile = Await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo)
    If file IsNot Nothing Then
        Dim bitmapImage As New BitmapImage()
        Using fileStream As IRandomAccessStream = Await file.OpenAsync(FileAccessMode.Read)
            bitmapImage.SetSource(fileStream)
        End Using

        ' Store the file path in Application Data
        appSettings(photoKey) = file.Path

    End If
Catch ex As Exception
End Try

Using this code is the picture getting saved somewhere ?

If so any idea where ?

How can I change the save location ?


Solution

  • I'm not 100% sure this is what you are after, but it might help:

    Dim saveDiag As New Pickers.FolderPicker
    Dim destFolder As Windows.Storage.StorageFolder = Await SaveDiag.PickSingleFolderAsync
    Await file.MoveAsync(destFolder)