使用streamreader读取文件

编程入门 行业动态 更新时间:2024-10-25 11:20:57
本文介绍了使用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 at IsolatedStorageFile.GetUserStoreForApplication() Here is a good example on this blog[^]

更多推荐

使用streamreader读取文件

本文发布于:2023-11-12 07:18:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580863.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   streamreader

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!