每当我尝试保存文件时,我都会收到此错误-
1. System.IO.IsolatedStorage.IsolatedStorageException was unhandled
Message=Operation not permitted on IsolatedStorageFileStream.
StackTrace:
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String
path, FileMode mode, FileAccess access, FileShare share, Int32
bufferSize, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String
path, FileMode mode, FileAccess access, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFile.OpenFile(String path,
FileMode mode, FileAccess access)
at PaintBrush.Save.savepic()
at PaintBrush.Save..ctor()
at PaintBrush.MainPage.click_btnSave(Object sender, RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs
e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl,
EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32
actualArgsTypeIndex, String eventName)
我正在尝试保存图像。我已经通过谷歌发现他们说在写入之前关闭文件流,但我无法理解。因为当我在写入之前关闭文件流时我遇到了同样的错误。这是我的代码-
public void savepic()
{
string filename=DateTime.Today.ToString()+".jpg";
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(filename, FileMode.Open, FileAccess.ReadWrite))
{
MediaLibrary mediaLibrary = new MediaLibrary();
Picture pic = mediaLibrary.SavePicture(filename, fileStream);
fileStream.Close();
}
}
PhotoChooserTask photoChooserTask = new PhotoChooserTask();
photoChooserTask.Show();
}