如何解决异常,在IsolatedFileStream上不允许操作?
调试之后,我意识到某条线没有被读取,它被跳过了捕获部分。我正在从Windows Phone 7中的照片样本中读取图像,并将其上传到skydrive。有人可以指导我如何解决这个问题吗? 感谢。
public BitmapImage fileName { get; set; }
private void GetImages()
{
MediaLibrary mediaLibrary = new MediaLibrary();
var pictures = mediaLibrary.Pictures;
foreach (var picture in pictures)
{
BitmapImage image = new BitmapImage();
image.SetSource(picture.GetImage());
MediaImage mediaImage = new MediaImage();
mediaImage.fileName = image;
UploadFile(mediaImage, picture.Name);
}
}
public void UploadFile(MediaImage image, string filepath)
{
if (skyDriveFolderID != string.Empty)
{
this.client.UploadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(ISFile_UploadCompleted);
infoTextBlock.Text = "Uploading backup...";
dateTextBlock.Text = "";
try
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
// error occurs HERE
IsolatedStorageFileStream readStream = myIsolatedStorage.OpenFile(filepath, FileMode.Open, FileAccess.Read);
readStream.Close();
this.client.UploadAsync(skyDriveFolderID, filepath, true, readStream, null)
}
}
答案 0 :(得分:0)
你确定那里会发生错误吗?我可以在阅读之前关闭流。所以可能是你错误的错误。
另外,您是否确定,具有该确切名称的文件存在于隔离存储中?