public static sbyte[] ReadBytes(FilePath file)
{
int length = (int)file.Length();
// should only be zero if loading from a network or similar
System.Diagnostics.Debug.Assert((length != 0));
sbyte[] bytes = new sbyte[length];
int totalBytesRead = 0;
FileInputStream inputStream = null;
try
{
inputStream = new FileInputStream(file);
while (totalBytesRead != length)
{
int bytesRead = inputStream.Read(bytes, totalBytesRead, length - totalBytesRead);
if (bytesRead == -1)
{
break;
}
totalBytesRead += bytesRead;
}
}
finally
{
if (inputStream != null)
{
inputStream.Close();
}
}
return bytes;
}