title: how to read and write a struct to file use C#?
body: <p>I can use write(&amp;stName,sizeof(stName),&amp;FileName) and define a same struct in other program to read the file(XXX.h) when i use C, But I want do the same use C# and I should not use the unsafe mode. How do to solve the problem?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>thanks all. I will to try them</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Now if I want to use C write the Struct to file.h and use C# to read the struct from file.h, may I have chance solve that and not to count the offset? Because count the offset is not a good answer when I want to add some variable or other struct in the struct.</p>