1

As I love to develop file I/O applications and my new development platform is Windows Mobile. Is there any way to read all the file, without using File.ReadAllText?

Because Windows Mobile doesn't have this function.

roundcrisis
  • 17,276
  • 14
  • 60
  • 92
Nathan Campos
  • 28,769
  • 59
  • 194
  • 300

2 Answers2

4

Write your own:

static string ReadAllText(string path) {
    using (var r = new StreamReader(path)) {
        return r.ReadToEnd();
    }
}
Frank Krueger
  • 69,552
  • 46
  • 163
  • 208
  • Thanks very much, I'm going to build a library of this, to use in future projects. – Nathan Campos Nov 12 '09 at 16:29
  • Good, I highly recommend building up a personal "augment library" that fixes missing bits from the BCL. But it's also important to learn the IO library in and out - saves a lot of time. – Frank Krueger Nov 12 '09 at 16:32
  • To keep its size down, the BCL omits methods that are just short-cuts, like File.ReadAllText, where is simple enough to write your own version. – Polyfun Nov 12 '09 at 16:42
1

A lot of the file operations are supported by the mobile framework, for example:

string text;
using (StreamReader reader = File.OpenText(fileName)) {
   text = reader.ReadToEnd();
}
Guffa
  • 687,336
  • 108
  • 737
  • 1,005