public static List<List<string>> ImportData()
{
List<List<string>> result = new List<List<string>>();
OpenFileDialog openDialog = new OpenFileDialog();
openDialog.ShowDialog();
if (!File.Exists(openDialog.FileName))
{
return result;
}
StreamReader sr =File.OpenText(openDialog.FileName);
try
{
while (!sr.EndOfStream)
{
string row = sr.ReadLine();
string[] datas = row.Split('/t');
List<string> rowString = new List<string>(datas);
result.Add(rowString);
}
}
finally
{
sr.Close();
}
return result;
}
public static void ExportData(List<List<string>> data)
{
SaveFileDialog saveDialog = new SaveFileDialog();
if (saveDialog.ShowDialog() == DialogResult.OK)
{
StreamWriter sw = File.CreateText(saveDialog.FileName);
try
{
foreach (var row in data)
{
sw.WriteLine(string.Join("/t", row.ToArray()));
}
}
finally
{
sw.Close();
}
}
}