windows-store-appswindowwinrt-async

save webcam captured image into local folder without using FileSavePicker


I am using Below Code to save image but it save image after filesavepicker save image but I want to save image direct into local folder without using filesavepicker,Please suggest me any Solution for this, thanks in Advance.

webcam private async Task SavePhoto(IRandomAccessStream mediaStream)
 {

   FileSavePicker photoSavePicker = new FileSavePicker();
   photoSavePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;                              
   var mediaFile = await photoSavePicker.PickSaveFileAsync();
   await SaveStreamToFileAsync(mediaStream, mediaFile);

}

I want to save this stream data in image format direct to local folder without using filesavepicker.


Solution

  • Create the StorageFile inside the app's LocalData. Then pass this StorageFile to your function.

    StorageFolder dirLocal = Windows.Storage.ApplicationData.Current.LocalFolder;
    StorageFile  mediaFile = await dirLocal.CreateFileAsync("mediaFile.abc");
    SaveStreamToFileAsync(mediaStream, mediaFile);