This assumes the file is just a series of doubles, one right after the other. If the DEM file is actually a text file, you can use a TextReader in place of the BinaryReader. Some additional code will be needed to parse the text into doubles (Double.Parse(string)) and handle the specifics of the DEM file format, which I'm not familiar with.
How to read big text file fast ?
AlexV
int rows, columns;
file = new BinaryReader(new FileStream(path, FileMode.Open));double value;
BinaryReader
rows = file.ReadInt32();
columns = file.ReadInt32(); for (int row = 0; row < rows; row++)
{
for (int column = 0; column < columns; column++)
{
value = file.ReadDouble();
}
}
file.Close();
This assumes the file is just a series of doubles, one right after the other. If the DEM file is actually a text file, you can use a TextReader in place of the BinaryReader. Some additional code will be needed to parse the text into doubles (Double.Parse(string)) and handle the specifics of the DEM file format, which I'm not familiar with.