After getting the file name I create a new filestream and load all the bytes from the FileStream into a byte array, now I need to get certain bytes and store them in fields like the second 4 bytes are the time the file was created. When storing these in the variables should I store them as bytes or as string/integers/etc.
Or have I done it completely wrong?
EDIT:Should I be doing this way instead of a filestream?
Dim data() as Byte = File.ReadAllBytes(path1)
Using
File.ReadAllBytesis a perfectly fine way of doing what you want to do. This is example of an aggregate component which uses several factored types under the covers to accomplish a common task. If you were to manually open aStreamReaderand read the contents of the file you would be re-coding the implementation ofFile.ReadAllBytesalmost exactly.An aggregate component is simply a type that provides a very high-level API over several lower-level types. The
Filetype is a perfect example of an aggregate component since it has many methods that allow you to do common tasks simply and without having to create and use the underlying types (or “factored types” likeStreamReader).I think what you have now is just fine – it is simple and straightforward (which is the entire reason aggregate components exist in the first place).