2012-05-01 28 views

回答

2

這可以讓你接近:

listBox1.Items.AddRange(File.ReadAllLines(@"c:\test.txt")); 
0

我不知道什麼.NET模仿特定的Delphi構造。您可能必須手動將文本行加載到列表框中。這很簡單:

// Read the file line by line 
System.IO.StreamReader file = new System.IO.StreamReader(@"c:\somefile.txt"); 
while((line = file.ReadLine()) != null) 
{ 
    //Add the line to the list box 
    listBox1.Items.Add(line); 
} 

file.Close(); 
相關問題