-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExporter.cs
53 lines (41 loc) · 1.17 KB
/
Exporter.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
using System;
using System.IO;
namespace ScrapingFromOurOwn
{
public class Exporter
{
public Exporter()
{
}
public static String exeDirectory() {
return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
}
public static String addColumn(String input, String label, String value, String value2 = "") {
if(String.IsNullOrEmpty(input.Trim()) == false) {
input += Environment.NewLine;
}
input += label;
input += "\t\t" + value;
if(String.IsNullOrEmpty(value2) == false) {
input += "\t\t" + value2;
}
return input;
}
// optional two-parameter variant
public static String addColumn(String label, String value) {
return addColumn("", label, value);
}
public static String addColumn(String label, String value, String value2) {
return addColumn("", label, value, value2);
}
public static void writeFile(String path, String content) {
try {
StreamWriter writer = new StreamWriter(path);
writer.Write(content);
writer.Close();
} catch (Exception e) {
Console.WriteLine("Execution failed. Invalid file name?\n\n{0}", e.ToString());
}
}
}
}