class CSVReader
{
public string[][] ParseCSV(string filename)
{
string[] linesOfFile;
string[][] cellsOfFile;
if (!File.Exists(filename))
throw new Exception(“File does not exist:”+filename);
linesOfFile = File.ReadAllLines(filename);
cellsOfFile = new string[linesOfFile.Length][];
for (int i = 0; i < linesOfFile.Length; i++)
cellsOfFile[i] = linesOfFile[i].Split(‘;’);
return cellsOfFile;
}
}
class TestCSVReader
{
public void Test()
{
string filename = “deneme.csv”;
string[][] cells = (new CSVReader()).ParseCSV(filename);
foreach (string[] line in cells)
foreach (string cell in line)
MessageBox.Show(cell);
}
}
0 cevap so far ↓
There are no comments yet...Kick things off by filling out the form below.