-
Notifications
You must be signed in to change notification settings - Fork 2
/
Class1.cs
63 lines (56 loc) · 1.91 KB
/
Class1.cs
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OCDataImporter
{
class InputReader
{
private String inputFilePath;
private ArrayList DataFileItems = new ArrayList();
/**
* Constructor
* @param name="inputFilePath" the full qualified path to the input file
*/
public InputReader(String inputFilePath)
{
this.inputFilePath = inputFilePath;
read();
}
private void read()
{
Get_DataFileItems_FromInput();
}
private bool Get_DataFileItems_FromInput()
{
// Find out how many data items are present per line and build array of data item names for using in data grid
DataFileItems.Clear();
sepcount = 1;
try
{
using (StreamReader sr = new StreamReader(theInputFile))
{
String line;
while ((line = sr.ReadLine()) != null)
{
line = line.Trim(); // 1.1b
if (line.Length == 0) continue;
linelen = line.Length;
if (line.IndexOf(tab) > 0) Delimiter = tab;
if (line.IndexOf(';') > 0) Delimiter = ';';
for (int i = 0; i < line.Length; i++) if (line[i] == Delimiter) sepcount++;
string[] spfirst = line.Split(Delimiter);
foreach (string one in spfirst) DataFileItems.Add(one);
break;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "OCDataImporter", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return (false);
}
return (true);
}
}
}