1

因为我喜欢开发文件 I/O 应用程序,而我的新开发平台是 Windows Mobile。有什么方法可以在不使用的情况下读取所有文件File.ReadAllText

因为Windows Mobile没有这个功能。

4

2 回答 2

4

自己写:

static string ReadAllText(string path) {
    using (var r = new StreamReader(path)) {
        return r.ReadToEnd();
    }
}
于 2009-11-12T16:25:39.727 回答
1

移动框架支持很多文件操作,例如:

string text;
using (StreamReader reader = File.OpenText(fileName)) {
   text = reader.ReadToEnd();
}
于 2009-11-12T16:26:58.330 回答