-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
83 lines (78 loc) · 3.21 KB
/
Program.cs
File metadata and controls
83 lines (78 loc) · 3.21 KB
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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TextSorter
{
class Program
{
static void Main(string[] args)
{
string dirPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\Downloads\Wien Raster\RasterFiles\";
string ergebnisDir = @"\Ergebnis\";
string ergebnisFile = "ergebnis.txt";
StringBuilder ergebnisString;
String[] allLines, files;
StreamWriter endErgebnis;
List<string> listString, zwischenSpeicher;
List<double> zwischenSpeicherDouble, endSpeicherDouble;
try
{
if (!Directory.Exists(dirPath+ergebnisDir))
{
Directory.CreateDirectory(dirPath+ergebnisDir);
}
if (!File.Exists(dirPath+ergebnisDir+ergebnisFile))
{
File.Create(dirPath + ergebnisDir + ergebnisFile).Close();
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadKey();
}
try
{
ergebnisString = new StringBuilder();
endErgebnis = new StreamWriter(dirPath + ergebnisDir + ergebnisFile);
files = Directory.GetFiles(dirPath);
int anzahlDirs = files.Length;
for (int i = 0; i < anzahlDirs; i++)
{
allLines = File.ReadAllLines(files[i]);
listString = new List<string>();
zwischenSpeicherDouble = new List<double>();
endSpeicherDouble = new List<double>();
zwischenSpeicher = new List<string>();
int anzahlZeilen = allLines.Length;
//ignoring first 6 Lines, .asc files have meta data in the first 6 lines, that are not relevant
for (int y = 6; y < anzahlZeilen; y++)
{
String[] split = allLines[y].Split(' ');
zwischenSpeicher = split.ToList();
zwischenSpeicherDouble = zwischenSpeicher.Select(x => double.Parse(x, CultureInfo.InvariantCulture)).ToList();
zwischenSpeicherDouble.Sort();
Console.Write("#");
endSpeicherDouble.AddRange(zwischenSpeicherDouble);
}
endSpeicherDouble.Sort();
ergebnisString.Append("File: " + files[i] + " Minimum: " + endSpeicherDouble.First() + " Maximum: " + endSpeicherDouble.Last()+"\n");
Console.WriteLine("\n\nEnde Datei_" + (i+1)+" von "+anzahlDirs+"\n\n");
}
endErgebnis.WriteLine(ergebnisString);
Console.WriteLine("ENDE");
Console.ReadKey();
endErgebnis.Close();
}
catch (Exception e)
{
Console.Write(e.ToString());
Console.ReadKey();
}
}
}
}