Autor Beitrag
Ivy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 228



BeitragVerfasst: Mi 16.12.09 10:15 
Hallo zusammen,
ich wüsste gerne wie man den Text der sich in einer txt Datei befindet in eine Textbox einschreiben lassen kann.

vielen dank schon mal =)
lg
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mi 16.12.09 10:25 
Hmm.. das hättest du bestimmt auch bei google gefunden.

Sind ja im Prinzip zwei Aufgaben
1) Dateiinhalt auslesen
2) Inhalt an Textbox zuweisen

Diese zwei Schritte gehen dann in einer Zeile:
ausblenden C#-Quelltext
1:
textBox1.Text = File.ReadToEnd("file.txt");					


Gruß Daniel
Ivy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 228



BeitragVerfasst: Mi 16.12.09 10:32 
"System.IO.File" enthält keine Definition für "ReadToEnd".

Kommt ein Fehler^^
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mi 16.12.09 10:40 
Augen auf... du findest die passende Funktion.
Ivy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 228



BeitragVerfasst: Mi 16.12.09 10:42 
ahja ich weiß grad nicht von was du sprichst :D aber okeee
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mi 16.12.09 10:46 
Ich nehme an du arbeitest mit Visual Studio.

Visual Studio bietet dir über die Intalisense einen Überblick über die Funktionen des jeweiligen Objekts. Wenn du also File. schreibst öffnet sich diese Intalisense für Klasse File. Methoden sind mit einem pinken Kästchen deklariert. Da steht auch die Methode drin, mit der du eine komplette Datei einließt.
Ivy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 228



BeitragVerfasst: Mi 16.12.09 10:48 
jo.. ReadAllLines hab ich ReadAllBytes und ReadAllText.
HAb ich auch davor schon alle probiert funktioniert aber nicht...
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Mi 16.12.09 10:49 
Wie funktioniert nicht - was meinst du damit?

ReadAllText find ich gut :)
Ivy Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 228



BeitragVerfasst: Mi 16.12.09 10:52 
ja jetz funktionierts, hatte den Befehl an der falschen stelle
super danke^^