How to create a .bin file?

Solved/Closed
lwm1017 Posts 1 Registration date Monday April 14, 2014 Status Member Last seen April 14, 2014 - Apr 14, 2014 at 12:21 AM
David Webb Posts 3177 Registration date Monday November 25, 2019 Status Administrator Last seen October 7, 2021 - Nov 26, 2019 at 09:10 AM
I need to create a new .bin file by combining a mp3 file and a cdg file for playing on my daughter's karaoke machine. Any suggestions?
Related:

3 replies

rozermartin28 Posts 1 Registration date Thursday April 10, 2014 Status Member Last seen April 14, 2014 5
Updated on Nov 26, 2019 at 09:07 AM
You can create a bin file with the help of the following instructions:

1.Add the namespace to the code page of your project. Writing and reading files requires the \"IO\" namespace. A namespace is a library of classes used by a developer. Writing to files requires the classes contained in the IO namespace. Add the following line to the beginning of your code file:

include System.IO;

2.Create the filestream variable and assign it to a binary stream. At this point, the file is created, but it is a blank binary file. Binary files can be created with any extension, but the standard is \".bin.\" Below is the code that creates the binary file:

FileStream file = new FileStream(\"C:\\\\mybinaryfile.bin\", FileMode.Create)
GO
BinaryWriter binarystream = new BinaryWriter(file);

3.Write to the binary file using the \"Write\" function. The Write function automatically encodes the values into binary mode, so there is no need to encode the information prior to saving it to the file. Below is an example of writing to a binary file:

binarystream.Write(\"My First Binary File\")
GO
binarystream.Write(10);

4.Close the file once all the information has been saved to the file. Closing the file is important in programming, because the process releases the file and unlocks it for use by users or other applications. The following line closes the binary file and saves it to the hard drive:

binarystream.Close();
5