Guest User

Untitled

a guest
Jul 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. string myData = File.ReadAllText("hexData.txt");
  2. string newData;
  3. int remainder = myData.Length%500;
  4. byte[] data_toWrite=newByte[250];
  5.  
  6. for(int i=0;i<myData.Length-remainder; i+=500)
  7. {
  8. newData = myData.Substring(i,500);
  9. data_toWrite = StringToByteArray(newData);
  10. File.WriteAllBytes("video.mjpeg",data_toWrite);
  11. }
  12.  
  13. newData = myData.Substring(myData.Length-remainder,remainder);
  14. data_toWrite = StringToByteArray(newData);
  15. File.WriteAllBytes("video.mjpeg",data_toWrite);
  16.  
  17. public static byte[] StringToByteArray(String hex)
  18. {
  19. int NumberChars = hex.Length;
  20. byte[] bytes = new byte[NumberChars / 2];
  21. for (int i = 0; i < NumberChars; i += 2)
  22. bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
  23. return bytes;
  24. }
Add Comment
Please, Sign In to add comment