using System using System Collections Generic using System Linq using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace KonvCSVerter
{
class FileReader
{
TwoForm tw;
public FileReader(string fileNames)
{
FileStream fs = new FileStream(fileNames, FileMode.Open, FileAccess.Read);
try
{
using (StreamReader file = new StreamReader(fs))
{
String line = file.ReadToEnd();
}
}
catch (Exception en)
{
MessageBox.Show("Файл не может быть прочитан");
MessageBox.Show(en.Message);
}
string[] lines = System.IO.File.ReadAllLines(fileNames, Encoding.Default);
string[] names = lines[7].Split(';');
for (int i = 1; i < names.Length; i++)
{
Two .Columns.Add(names[i], typeof(string));
}
for (int i = 9; i < lines.Length; i++)
{
csvData.Rows.Add(lines[i].Substring(lines[i].IndexOf(';') + 1).Split(';'));
}
}
}
}