   Using fread in c#
  When i was using fread to read files, i discovered that there's one really weird problem. To make sure what was going on i made a file that has bytes from 0 to 255 written inside and this is how i read it:IntPtr P = IntPtr.Zero;P = BinFile.fopen(@"C:\bleh.txt", "r");byte b = 0;for (int i = 0; i < 255; i++){    b = 0;    BinFile.fread(&b, sizeof(byte), 1, P);    Console.WriteLine(b);}BinFile.fclose(P);Also this is how i use fopen and fread:[DllImport("MSVCRT.DLL")]public static extern IntPtr fopen(string Path, string Mode);[DllImport("MSVCRT.DLL")]public static extern IntPtr fread(void* Buffer, uint Size, uint Count, IntPtr Stream);Well anyways... when i was reading it and it was about to read byte with the value of 26, it fails to read it and it fails with the next ones too. It seems to fail every time there's byte 26 to read.Does anybody have any idea what's going on and how to make read it right?   
  Did you try opening the file as binary?   ;  You do realize that there is an entire System.IO namespace right?   ;  Why on earth are you using fread?   ;  Because i can use fread to read a whole structure out of the file in one code line.   ;  You do realize that there is an entire System.Runtime.Serialization namespace right?   ;  I just realized that before you said it by the way.And way to go solving the problem.   ;  Google and "xmlserializer c#" => this.   ;Quote:Original post by tanel1993I just realized that before you said it by the way.And way to go solving the problem.The problem is that you're using an old and decrepit C API in a modern managed language. I've pointed you towards a correct solution to your real problem, even if you can't realize it. Trying to get fread to work will just be a waste of your time.   