I am new to c# and trying to read a binary file. I do so in c++ like this :
int main(int argc, char * * argv)
{
FILE * fp;
fp = fopen(argv[1], "rb"); //argv[1] because while executing at terminal the binary file to be read is at second postion like "./filename.c BinaryInutFile.bin" so at argv[0] we have ./filename.c and at argv[1] we have Binaryfile.bin
ch = fgetc(fp);
while (fread( & ch, sizeof(ch), 1, fp))
{
add_symbol(ch); //this add_symbol()i will use somewhere else, so not so important for now.
}
fclose(fp);
}
So i want help in writing equivalent c# code.Thanks to the helpers. Note: I don't know the size of file and name of the file as well but it's a binary file, I mean the user can change the binary file at terminal it should work for all the number of binary files he check for output. And i will execute at terminal like this "mono filename.exe BinaryFile.bin" where filename.exe is the file which was formed by compiling the filename.cs (by doing "gmcs filename.cs") which contain this code and BinaryFile.cs will be the bbianry file to be tested on my code and "mono" i have used because i am working on Ubantu and i compile using "gmcs FileName.cs" which will give Filename.exe and then execute it as "mono filename.exe BinaryFile.bin"