I'd suggest you focus on serializing/writing an XML file, or a JSON file, as outlined below.
Whichever format you used, de-serializing/reading the file back into an Array would be easy.
The "catch" is, as you may know, that .NET's Serialize facility does not support multi-dimensional Arrays.
You could easily use something like the FastJSON serializer/de-serializer by Mehdi Gholam here on CP, which
will handle multi-dimensional Arrays: [
^],
and the resulting file would be fairly human-readable.
Another technique is to make your Array a jagged Array: i.e., short[][]: that
can be serialized; see: [
^]. If you re-structured your Array like this:
private short[][] AlleCoordinaten2 = new short[3][]
{
new short[] {1,2,3,4,5,6},
new short[] {6,5,4,3,2,1},
new short[] {2,3,4,5,6,7}
};
You could then write it to XMl like this:
using System.IO;
using System.Xml.Serialization;
private string fPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
private void WriteArrayToXML_Click(object sender, EventArgs e)
{
using (var stream = File.Create(fPath + @"/AlleCoordinaten.xml"))
{
var serializer = new XmlSerializer(typeof(short[][]));
serializer.Serialize(stream, AlleCoordinaten2);
}
}
The resulting XML would look like this:
<arrayofarrayofshort xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<arrayofshort>
<short>1</short>
<short>2</short>
<short>3</short>
<short>4</short>
<short>5</short>
<short>6</short>
</arrayofshort>
<arrayofshort>
<short>6</short>
<short>5</short>
<short>4</short>
<short>3</short>
<short>2</short>
<short>1</short>
</arrayofshort>
<arrayofshort>
<short>2</short>
<short>3</short>
<short>4</short>
<short>5</short>
<short>6</short>
<short>7</short>
</arrayofshort>
</arrayofarrayofshort>
Some folks write code to convert multi-dimensional arrays to jagged arrays for serialization, and the reverse: you can find discussion of that by Googling on: "serialize jagged arrays." I'd try to avoid techniques like those, if possible.