1.文字檔內容(以逗號將每欄位隔開):
SRV1,192.168.100.1,C:\,100,200
SRV2,192.168.100.2,C:\,100,200
SRV3,192.168.100.3,C:\,100,200
2.程式碼
private void Form1_Load(object sender, EventArgs e)
{
TextReader txtReader = new StreamReader(@".\DiskInfo.txt");
while (txtReader.Peek() != -1)
{
string[] parts = txtReader.ReadLine().Split(',');
dataGridView1.Rows.Add(parts);
}
txtReader.Close();
}