If I’m not mistaken ReadAllText() is part of the 2.0 Framework, and if you
are using 1.0 or 1.1 you would have to take a step back and do something a
little longer such as:
memo1.Text = File.OpenText("myfile.txt").ReadToEnd();
You are still ultimately dealing with a StreamReader, however a little more
indirectly and inline with Nicholas’s example.
Brendan
[quoted text, click to view] "Nicholas Paldino [.NET/C# MVP]" wrote:
> Chris,
>
> You can use the static ReadAllText method on the File class in the
> System.IO namespace, like so:
>
> // Set the text in the textbox.
> textbox1.Text = File.ReadAllText("filename");
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@spam.guard.caspershouse.com
>
> "Chris" <noname@nospam.be> wrote in message
> news:8v3od1d8ad627tvtr4svjon82ut54dmvm8@4ax.com...
> > Hi,
> >
> > In Delphi there is the possibilty to load a textfile into a textfield
> > (memo) without writing too much code. It goes like
> > memo1.Lines.LoadFromFile('myfile.txt');
> >
> > What is the C# equivalent (without making use of a streamreader)?
> >
> > Cheers,
> >
> > Chris
>
>
Chris,
You can use the static ReadAllText method on the File class in the
System.IO namespace, like so:
// Set the text in the textbox.
textbox1.Text = File.ReadAllText("filename");
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
[quoted text, click to view] "Chris" <noname@nospam.be> wrote in message
news:8v3od1d8ad627tvtr4svjon82ut54dmvm8@4ax.com...
> Hi,
>
> In Delphi there is the possibilty to load a textfile into a textfield
> (memo) without writing too much code. It goes like
> memo1.Lines.LoadFromFile('myfile.txt');
>
> What is the C# equivalent (without making use of a streamreader)?
>
> Cheers,
>
> Chris
Hi,
In Delphi there is the possibilty to load a textfile into a textfield
(memo) without writing too much code. It goes like
memo1.Lines.LoadFromFile('myfile.txt');
What is the C# equivalent (without making use of a streamreader)?
Cheers,