访问被拒绝。 (Windows手机8.1应用程序中的HRESULT异常:0x80070005(E_ACCESSDENIED))

时间:2016-07-15 10:46:46

标签: c# windows-phone-8.1 unauthorizedaccessexcepti

我正在尝试从媒体捕获元素中获取图像,当我尝试打开该文件时,此时#34;访问被拒绝。 (HRESULT异常:0x80070005(E_ACCESSDENIED))"发生例外......

try
        {
            var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("takeImage.png", CreationCollisionOption.ReplaceExisting);

            if (file != null)
            {
                _mediaCapture.CapturePhotoToStorageFileAsync(ImageEncodingProperties.CreatePng(), file);
                ImageProperties imgProp = await file.Properties.GetImagePropertiesAsync();

                //LINE IS WHERE EXCEPTION HAPPENS..
                using (var imgStream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    bitmap = new WriteableBitmap((int)imgProp.Width, (int)imgProp.Height);
                    bitmap.SetSource(imgStream);
                    PreviewImage.Source = bitmap;
                }
            }
        }
        catch (Exception ex)
        { 
            ex.Message;
        }

0 个答案:

没有答案