Windows Phone 7:文件流异常
我尝试使用 FileStream (使用命名空间 System.IO),但出现异常:
Attempt to access the method failed
以下是代码:
FileStream fs = new FileStream("file.txt", FileMode.Create);
我在 microsoft.com 上搜索,发现此错误是因为我使用了错误的库引用。
但在我的项目中,我使用文件夹中的 mscorlib.dll 进行编译:C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0
我需要一些帮助。
I try to use FileStream (using namespace System.IO) but I get an exception :
Attempt to access the method failed
Here is the code :
FileStream fs = new FileStream("file.txt", FileMode.Create);
I searched on microsoft.com and I found that this error is because I use a bad library reference.
But in my project, I compile with mscorlib.dll from folder : C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0
I need some help, please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将需要使用IsolatedStorage,例如:
放在文件的顶部:
然后在您的方法中执行以下操作:
可以在此处找到此操作和其他操作的一个很好的示例和说明:http://msdn.microsoft.com/en-us/library/cc265154(v=VS.95).aspx# Y300
您可以使用Windows Phone 7isolatedStorageExplorer查看您的IsolatedStorage
。文档: http://msdn.microsoft.com/library/ff626516( v=VS.92).aspx
另请参阅:http://create。 msdn.com/en-us/education/documentation
You will need to use IsolatedStorage, for example:
Place at the top of your file:
Then in your method do this:
A great example and explanation of this and other operations can be found here: http://msdn.microsoft.com/en-us/library/cc265154(v=VS.95).aspx#Y300
You can look through your IsolatedStorage by using the Windows Phone 7 IsolatedStorageExplorer
A good place to start for documentation: http://msdn.microsoft.com/library/ff626516(v=VS.92).aspx
Also here: http://create.msdn.com/en-us/education/documentation
在 WindowsPhone 上,您必须使用isolatedStorage - 例如,请参阅本教程 - http://3water.wordpress.com/2010/08/07/isolated-storage-on-wp7-ii/
读:
写:
On WindowsPhone you must use IsolatedStorage - see this tutorial for example - http://3water.wordpress.com/2010/08/07/isolated-storage-on-wp7-ii/
Read:
Write: