0

I'm building an app that needs to take a photo with webcam and save it to the local disk, so far I have this:

async private void CapturePhoto_Click(object sender, RoutedEventArgs e)
    {
        Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
        ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();


        // create storage file in local app storage
        StorageFile file = await localFolder.CreateFileAsync("TestPhoto.jpg", CreationCollisionOption.GenerateUniqueName);

        StorageFile localFile = await localFolder.CreateFileAsync("webcamPhotoTest.jpg", CreationCollisionOption.ReplaceExisting);

        // take photo 
        // save to app storage
        await captureManager.CapturePhotoToStorageFileAsync(imgFormat, file);

        // save to local storage
        await captureManager.CapturePhotoToStorageFileAsync(imgFormat, localFile);

        // Get photo as a BitmapImage
        BitmapImage bmpImage = new BitmapImage(new Uri(file.Path));

        // imagePreview is a <Image> object defined in XAML
        imagePreview.Source = bmpImage;

    }

I am able to save the jpg image both to app storage and local storage but I need to be able to a) Specify the path to save to b) do so without requiring user interaction (e.g windows save file prompt)

There are no support for System.Drawing in Windows 8 apps which complicates things. Most answers I've found have either been using System.Drawing features or windows' save file prompt.

Essah
  • 899
  • 2
  • 8
  • 20
  • Do you know where you want to save it? Maybe look here: http://stackoverflow.com/questions/4161359/save-bitmapimage-to-file – Michael B Jan 16 '14 at 10:44
  • yes, but for now anywhere will do. Can always change path later. Point is to be able to specify it. The link you provided appears to be about downloading and saving rather than saving from the application. – Essah Jan 16 '14 at 10:48

1 Answers1

0

You can't really use any location that you want. There is the list of locations that you can access from your app: File access and permissions in Windows Store apps. Some locations require additional declarations in the manifest file of your project.

crea7or
  • 4,421
  • 2
  • 26
  • 37