PersonListViewDialog
public List<Person> pList = new List<Person>();
-FileIO
private void LoadFile(string path)
{
if (File.Exists(path))
{
System.Diagnostics.Trace.WriteLine(path);
// 한글처리시 필요함
using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default))
{
string line = “”;
char[] delimiter = { ‘,’ };
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
// cvs file format parse
string[] items = line.Split(delimiter);
foreach (string s in items)
{
Console.WriteLine(s);
}
// add Person into the List
Person p = new Person();
p.Name = items[0];
p.ID = int.Parse(items[1]);
p.Phone = items[2];
p.Address = items[3];
pList.Add(p);
// add Person into ListView Control
listView1.Items.Add(p.ToListViewItem());
}
sr.Close();
}
}
}
private void WriteFile(string path)
{
// 한글처리시 필요함
using (StreamWriter sw = new StreamWriter(path, false, System.Text.Encoding.Default))
{
foreach (Person p in pList)
sw.WriteLine(p); // Person에 ToString() 사용
sw.Close();
}
}
-Modal형 AddDialog
-Modeless형 FindDialog