String StoredHexValues = "SEE Hex_Values.txt TEXT FILE" īyte Bytes2 = ConvertHexToByteArray(StoredHexValues) Hex Values for Microsoft's Sound Recorder String Filename = Bytes1 = File.ReadAllBytes(Filename) Ĭonsole.WriteLine(ConvertByteToHex(Bytes1)) String byteValue = hexString.Substring(index * 2, 2) īyteArray = byte.Parse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture) Public static byte ConvertHexToByteArray(string hexString)īyte byteArray = new byte įor (int index = 0 index < byteArray.Length index++) convert hex values of file back to bytes String hexValues = BitConverter.ToString(byteData).Replace("-", "") Public static string ConvertByteToHex(byte byteData) convert byte array from file to hex values Why would you want to do this? To store extra resource files as hex values in your code (thus, no longer requiring the files)…this works in most languages, including PowerShell and Python. This is how you would convert a file to a byte array, convert the byte array to hex values, store those hex values in a string, convert the hex values back to a byte array, and then reconstitute the original file from the stored hex values.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |