我有這樣的代碼,使我的windows phone的截圖:什麼是System.UnauthorizedAccessException?
private void TakeScreenShot()
{
// Take a screenshot
var screenshot = new WriteableBitmap(this, null);
var screenshotname = String.Format("Screenshooter_{0}", DateTime.Now.Ticks);
using (var ms = new MemoryStream())
{
screenshot.SaveJpeg(ms, 480, 800, 0, 85);
ms.Seek(0, SeekOrigin.Begin);
var library = new MediaLibrary();
var pic = library.SavePicture(screenshotname, ms);
}
MessageBox.Show(string.Concat("Screenshot saved as ", screenshotname));
}
但是我有一個exeption(System.UnauthorizedAccessException的)指令:
var pic = library.SavePicture(screenshotname, ms);
如何拋出異常?提前致謝。
['UnauthorizedAccessException'](http://msdn.microsoft.com/en-us/library/system.unauthorizedaccessexception(v = vs.110) ).aspx)通常意味着由於'MediaLibrary'中的'I/O',您有安全問題或訪問問題。 –
您無權寫入'MediaLibrary'。 –
好的,我添加了ID_CAP_MEDIALIB_PHOTO,它工作正常;) –