异常在 Microsoft.Xna.Framework.ni.dll 中发生,但未在用户代码中进行处理
rt,保存照片的时候报错!怎么处理呢??
void ct_Completed(object sender, PhotoResult e)
{
if (null != e.Error)
{
MessageBox.Show("Error");
return;
}
else if (e.TaskResult == TaskResult.OK)
{
using (e.ChosenPhoto)
{
MediaLibrary ml = new MediaLibrary();
ml.SavePicture("p",e.ChosenPhoto);
}
}
}
IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
try
{
if (!file.DirectoryExists(albumId.Text))
{
file.CreateDirectory(albumId.Text);
}
IsolatedStorageFileStream fs = file.CreateFile(imagePath);
ImageSource imageSource = imageFile.Source;
BitmapImage tempImage = imageSource as BitmapImage;
WriteableBitmap wb = new WriteableBitmap(tempImage);
wb.SaveJpeg(fs, wb.PixelWidth, wb.PixelHeight, 0, 100);
fs.Close();
fs = file.OpenFile(imagePath, FileMode.Open, FileAccess.Read);
MediaLibrary mLib = new MediaLibrary();
mLib.SavePicture(imageId.Text, fs);
fs.Close();
fs.Dispose();
}