[英]WP7 Exception error - Operation not permitted on IsolatedStorageFileStream
How do I solve the exception, Operation not permitted on IsolatedFileStream? 如何解决例外情况,不允许对IsolatedFileStream进行操作?
After debugging, I realised that a certain line wasn't read and it was skipped to the catch part. 调试后,我意识到未读取特定的行,因此将其跳过到catch部分。 I am reading images from the photo samples in windows phone 7 as well as uploading them into skydrive. 我正在从Windows Phone 7的照片样本中读取图像,并将它们上传到skydrive中。 Can anybody guide me on how to solve this problem asap? 谁能尽快指导我解决这个问题? Thanks. 谢谢。
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)
}
}
Are you sure error occurs there? 您确定那里发生错误吗? I can se you are closing the stream before reading it. 我可以确定您在阅读之前关闭了流。 So it may be that you got the line of error wrong. 因此,可能是您错了错误线。
Also, are you absolutely sure, that file with that exact name exists in Isolated Storage? 另外,您绝对确定隔离存储中存在具有相同名称的文件吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.