1つのテキストファイルからデータのセットを1つのテキストボックスに読み込み、印刷します.




  
    
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main( string [] args)
{

// The files used here were created in the code example
// in How to: Write to a Text File. You can of course substitute
// other files of your own.

// Example #1
// Read the file as one string.
string text = System.IO.File.ReadAllText( @" D:\Test1.txt " );

// Display the file contents to the console.
System.Console.WriteLine( @" D:\Test1.txt = {0} " , text);

// Example #2
// Read the file lines into a string array.
string [] lines = System.IO.File.ReadAllLines( @" D:\Test2.txt " );

System.Console.WriteLine(
@" D:\Test2.txt =: " );
foreach ( string line in lines)
{
Console.WriteLine(
" \t " + line);
}

// Keep the console window open in debug mode.
Console.WriteLine( " Press any key to exit. " );
System.Console.ReadKey(); }


}
}