保存camera StorageFile文件

        private async void TakeSnapShotButton_Click(object sender, RoutedEventArgs e)
        {
            CameraCaptureUI ccu = new CameraCaptureUI();
            ccu.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png;
            ccu.PhotoSettings.AllowCropping = false;
            StorageFile photo =await ccu.CaptureFileAsync(CameraCaptureUIMode.Photo);
            if (photo is null)
                return;
            else
            {
                TemporaryPhotoFile = photo;
                BitmapImage bitMapImage = new BitmapImage();
                FileRandomAccessStream fRAS = (FileRandomAccessStream)await photo.OpenAsync(FileAccessMode.Read);
                bitMapImage.SetSource(fRAS);
                yourPhoto.Source = bitMapImage;
 
 
                /// 保存 StorageFile文件到磁盘
                StorageFolder destinationFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync
                    (yourName.Text,CreationCollisionOption.OpenIfExists);
                await photo.MoveAsync(destinationFolder, "ProfilePhoto.jpg", NameCollisionOption.ReplaceExisting);
                await photo.DeleteAsync();
 
 
            }
        }

  

posted @ 2018-01-20 21:19  奔跑的蒲公英  阅读(286)  评论(0编辑  收藏  举报