silverlight   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了silverlight – 在文件打开时抛出IsolatedStorageFileStream异常?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

当我尝试在WP7应用程序中打开文件时: IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream nameXmlFile = new IsolatedStorageFileStream("Names.xml", System.IO.FileMode.op
当我尝试在WP7应用程序中打开文件时: @H_301_7@

@H_301_7@

IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream nameXmlFile = new IsolatedStorageFileStream("Names.xml",System.IO.FileMode.open,isf);
@H_301_7@我收到以下错误

@H_301_7@

@H_301_7@我不确定为什么它没有打开,因为我在我的应用程序的其他地方使用了确切的代码,它工作正常.
关于为什么会发生这种情况的任何线索?

@H_301_7@编辑

@H_301_7@我使用以下代码文件添加到App.xaml.cs Application_Launching事件中的独立存储:

@H_301_7@

IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream FeedXmlFile = new IsolatedStorageFileStream("Names.xml",System.IO.FileMode.Create,isf);

解决方法

使用IsolatedStorageFileStream构造函数一个问题是生成异常信息有限.替代的OpenFile方法有一组更丰富的例外. @H_301_7@

@H_301_7@作为一般的经验法则,如果API允许您使用构造函数方法执行相同的操作,请使用该方法.在这种情况下,请尝试使用此代码: –

@H_301_7@

IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream nameXmlFile = isf.openFile("Names.xml",System.IO.FileMode.open);
@H_301_7@如果失败,您将至少缩小潜在原因.

@H_301_7@这看起来很明显但是在您创建的代码中,您实际上已经写入并关闭了您创建的文件

大佬总结

以上是大佬教程为你收集整理的silverlight – 在文件打开时抛出IsolatedStorageFileStream异常?全部内容,希望文章能够帮你解决silverlight – 在文件打开时抛出IsolatedStorageFileStream异常?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。