Tag Archives: read byte array

C# || How To Save, Open & Read File As A Byte Array & Memory Stream Using C#

The following is a module with functions which demonstrates how to save, open and read a file as a byte array and memory stream using C#.


1. Read File – Byte Array

The example below demonstrates the use of ‘Utils.Methods.ReadFile‘ to read a file as a byte array.


2. Read File – Memory Stream

The example below demonstrates the use of ‘Utils.Methods.ReadFile‘ to read a file as a memory stream.


3. Save File – Byte Array

The example below demonstrates the use of ‘Utils.Methods.SaveFile‘ to save the contents of a byte array to a file.


4. Save File – Memory Stream

The example below demonstrates the use of ‘Utils.Methods.SaveFile‘ to save the contents of a memory stream to a file.


5. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


6. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

VB.NET || How To Save, Open & Read File As A Byte Array & Memory Stream Using VB.NET

The following is a module with functions which demonstrates how to save, open and read a file as a byte array and memory stream using VB.NET.


1. Read File – Byte Array

The example below demonstrates the use of ‘Utils.ReadFile‘ to read a file as a byte array.


2. Read File – Memory Stream

The example below demonstrates the use of ‘Utils.ReadFile‘ to read a file as a memory stream.


3. Save File – Byte Array

The example below demonstrates the use of ‘Utils.SaveFile‘ to save the contents of a byte array to a file.


4. Save File – Memory Stream

The example below demonstrates the use of ‘Utils.SaveFile‘ to save the contents of a memory stream to a file.


5. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


6. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.