我使用以下代码在隔离存储中创建文件
mystorage = IsolatedStorageFile.GetUserStoreForApplication();
if (mystorage.FileExists(scanName))
{
mystorage.DeleteFile(scanName);
}
WriteableBitmap wb = new WriteableBitmap(canImage, null);
using (MemoryStream stream = new MemoryStream())
{
wb.SaveJpeg(stream, (int)canImage.Width, (int)canImage.Height, 0, 100);
using (IsolatedStorageFileStream local = new IsolatedStorageFileStream(scanName, FileMode.Create, mystorage))
{
local.Write(stream.GetBuffer(), 0, stream.GetBuffer().Length);
}
}
if (MessageBox.Show("Scan updated successfully") == MessageBoxResult.OK)
{
App.isTransformRequest = false;
NavigationService.Navigate(new Uri("/View/EditDocument.xaml?paramList=" + App.currentName, UriKind.RelativeOrAbsolute));
}
此代码工作正常。但我想检测文件完全创建与否的天气,之后只想显示成功消息。我正在使用somtimes的方式在完全创建文件之前显示成功消息,我希望仅在完全创建文件后才显示消息,即完全写入流。