使用streamreader读取文件 [英] reading a file using streamreader
本文介绍了使用streamreader读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Windows Mobile 7中工作
我在项目中添加了文件"Book.txt".
我想用代码阅读-
Hye,
i am working in windows mobile 7
I have added a file "Book.txt" in my project.
and i want to read it using the code -
using (StreamReader reader = new StreamReader("Book.txt"))
{
string content = reader.ReadLine();
string[] str = content.Split(",".ToCharArray());
Book newB = new Book();
newB.bookId = int.Parse(str[0]);
newB.volumeId = int.Parse(str[1]);
return newB
}
但它给出了错误-
尝试访问方法失败的system.io.streamreader..ctor system.string
在线-
使用(StreamReader reader = new StreamReader("Book.txt"))
我现在该怎么办.....
在此先感谢....
but it gives error -
attempt to access the method failed system.io.streamreader..ctor system.string
at the line -
using (StreamReader reader = new StreamReader("Book.txt"))
what should i do now.....
thanks in advance....
推荐答案
Windows Phone 7被沙盒化了,因此,您不能像台式机那样进行IO.看看IsolatedStorageFile.GetUserStoreForApplication()
这是关于博客 [ ^ ]
Windows Phone 7 is sandboxed, thus, you can not do IO like Desktop. Look atIsolatedStorageFile.GetUserStoreForApplication()
Here is a good example on this blog[^]
这篇关于使用streamreader读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文