-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileTypes.cs
85 lines (75 loc) · 2.48 KB
/
FileTypes.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileCrawler
{
class FileTypes
{
List<String> fileList = new List<string>();
static StreamReader reader;
public List<String> GetFileTypesToDownlaod(String p)
{
string[] files = Directory.GetFiles(p);
foreach (String filePath in files)
{
ReadCSVToOne(filePath);
}
return fileList;
}
public String GetConnectionString(String p)
{
int counter = 0;
string line;
String returnVal = "Please Update the app data file.";
// Read the file and display it line by line.
reader = new System.IO.StreamReader(p);
while ((line = reader.ReadLine()) != null)
{
String[] connectionString = line.Trim().Split(',');
if (connectionString[0].ToString() == "ConnectionString")
{
returnVal = connectionString[1];
}
counter++;
}
reader.Close();
return returnVal;
}
public String GetHostToCrawlString(String p)
{
int counter = 0;
string line;
String returnVal = "Please Update the app data file.";
// Read the file and display it line by line.
reader = new System.IO.StreamReader(p);
while ((line = reader.ReadLine()) != null)
{
String[] connectionString = line.Trim().Split(',');
if (connectionString[0].ToString() == "WebsiteName")
{
returnVal = connectionString[1];
}
counter++;
}
reader.Close();
return returnVal;
}
private void ReadCSVToOne(String filePath)
{
int counter = 0;
string line;
// Read the file and display it line by line.
reader = new System.IO.StreamReader(filePath);
while ((line = reader.ReadLine()) != null)
{
String fileName = Path.GetFileName(filePath).ToString().Substring(0, Path.GetFileName(filePath).ToString().Length-4);
fileList.Add(line+","+fileName);
counter++;
}
reader.Close();
}
}
}