How can I read all text when ReadAllText is unavailable?

B. Clay Shannon

I want to assign the contents of a text file to a textbox, like so:

String logDirPath = 
    Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
String fullPath = logDirPath + "\\application.log";
textBoxErrLogsContents.Text = File.ReadAllText(fullPath);

I got the "ReadAllText" from here, but it's not available to me.

I am referencing mscorlib, and I did add a "using System.IO;" but it's grayed out, while ReadAllText is fire-engine red.

Am I missing something, or do I have to skin this cat some other way in this Windows CE / Compact Framework app?

Luke Hutton

The compact-framework edition does not implement it. The .net version, however, is simply implemented like this:

public static class File
{
    public static String ReadAllText(String path)
    {
        using (var sr = new StreamReader(path, Encoding.UTF8))
        {
            return sr.ReadToEnd();
        }
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I obtain only word without All Punctuation Marks when I read text file?

From Dev

How can I force Word 2016 to read all text in Text to Speech?

From Dev

How can I read all data from text plain using xslt in Java?

From Dev

How to save and read text file using File.ReadAllText() from application startup?

From Dev

How can I rasterize all of the text in a PDF?

From Dev

How can i read the text from richTextbox and keep the format of the text?

From Dev

How can i format the NumPr when i read

From Dev

How do I create a custom entity that can be read by all users?

From Dev

How can I read the contents of all the files in a directory with pandas?

From Dev

How can I read All Items in table of table with lua api?

From Dev

How can I read all target URLs in IdHTTPProxyServer

From Dev

How can I read all elements in a table with jsoup

From Dev

How can I read All Items in table of table with lua api?

From Dev

How can I read and parse text files with configurable contents?

From Dev

in Oracle, how can i read a large blob as a text document

From Dev

How can i read specific text from txt file in android

From Dev

how can I read multiple text files in matlab?

From Dev

How can I read only text files in a directory?

From Dev

How can I read a text file with scala.js?

From Dev

How can I read and replace Strings line by line in a Text File?

From Dev

Android - How can I read a text file from a url?

From Dev

how can I read a text file, process it & write toString()

From Dev

how can I read multiple text files in matlab?

From Dev

how can I read from an uploaded text file

From Dev

How can I read the data from text file and load it into the vector?

From Dev

How can I read out text on my computer?

From Dev

C++ How can I read phrases from a text file?

From Dev

How can I see unavailable servers in Nginx logs?

From Dev

How can I make Jest handle an ElasticSearch server being unavailable?

Related Related

  1. 1

    How can I obtain only word without All Punctuation Marks when I read text file?

  2. 2

    How can I force Word 2016 to read all text in Text to Speech?

  3. 3

    How can I read all data from text plain using xslt in Java?

  4. 4

    How to save and read text file using File.ReadAllText() from application startup?

  5. 5

    How can I rasterize all of the text in a PDF?

  6. 6

    How can i read the text from richTextbox and keep the format of the text?

  7. 7

    How can i format the NumPr when i read

  8. 8

    How do I create a custom entity that can be read by all users?

  9. 9

    How can I read the contents of all the files in a directory with pandas?

  10. 10

    How can I read All Items in table of table with lua api?

  11. 11

    How can I read all target URLs in IdHTTPProxyServer

  12. 12

    How can I read all elements in a table with jsoup

  13. 13

    How can I read All Items in table of table with lua api?

  14. 14

    How can I read and parse text files with configurable contents?

  15. 15

    in Oracle, how can i read a large blob as a text document

  16. 16

    How can i read specific text from txt file in android

  17. 17

    how can I read multiple text files in matlab?

  18. 18

    How can I read only text files in a directory?

  19. 19

    How can I read a text file with scala.js?

  20. 20

    How can I read and replace Strings line by line in a Text File?

  21. 21

    Android - How can I read a text file from a url?

  22. 22

    how can I read a text file, process it & write toString()

  23. 23

    how can I read multiple text files in matlab?

  24. 24

    how can I read from an uploaded text file

  25. 25

    How can I read the data from text file and load it into the vector?

  26. 26

    How can I read out text on my computer?

  27. 27

    C++ How can I read phrases from a text file?

  28. 28

    How can I see unavailable servers in Nginx logs?

  29. 29

    How can I make Jest handle an ElasticSearch server being unavailable?

HotTag

Archive