Ok, So I am writing another program for the purpose of manipulating binary files. This program is importing a file larger than anything I have had to manipulate before, about 12K.
I'm curious as to how the Stream.read command works....I know that this sounds elementary, but how can I tell that the file has been read completely so that I can begin manipulating it, as of right now I have this code...
// Opens a stream to the path chosen in the open file dialog
using (FileStream stream = new FileStream(chosenFile, FileMode.Open, FileAccess.Read))
{
size = (int)stream.Length; // Returns the length of the file
data = new byte[size]; // Initializes and array in which to store the file
stream.Read(data, 0, size); // Begins to read from the constructed stream
progressBar1.Maximum = size;
while (byteCounter < size)
{
int i = data[byteCounter];
byteCounter++;
progressBar1.Increment(1);
}
}
I Understand that this is very very simple, but can someone explain to me how stream.Read works, does it store everything into the byte array "data" and then I can manipulate that as I see fit, or do I have to manipulate the file as it is being read. Again I apologize if this is elementary, all thoughts are appreciated