If I Open a file using something like:
FileStream^ fs = File::OpenRead( path );
How can I determine the size of the file so that I can read
all of the data bytes in the file? What sort of Read would
you use to read one byte at a time. Would you open a buffer
(say 1024 bytes) and index into the array for each character?
array<Byte>^b = gcnew array<Byte>(1024);
Or would you use a read buffer size of 1 byte ch[1] as a
buffer.array<Byte>^b = gcnew array<Byte>(1);
fs->Read ( b, 0, 1 );
How would you handle the end of thie file so that
you know how many bytes are in the file?
I need to scan a file to turn off 1 or more bits in each of the bytes
in the file and write out these data to a new "copy" of the file with those bits turned off using a bitwise AND of each byte in the input file.
I will also need to seek using random access to certain spots in the
input file. I have seen an example:
fs->Seek (15, SeekOrigin::Current);
This moves the "read cursor" 15 chars further and
fs->Seek (15, SeekOrigin::Begin);
I see "Begin" so I assume that you could use "End"? I have
also shown an example that uses "Current". Are there any
more usages. Could you tell the size of the file by simple
subtracting (End - Begin). How would you write this code?
I understand that you can use SeekOrigin with BaseStream and Seek to set the file pointer of the underlying stream to the beginning. I need more examples of this. in another example I see:
Something like this:
fs.BaseStream.Seek(0, SeekOrigin.End)
What is with this example?
I am new to c++ and the FileStream way of accessing file data. I am
quite confused about this and need some help. Thank you in advance for any help or examples that might be useful.
All the best!
73
-Grace
NNNN
z