Код: Выделить всё
string ReadAllBytes()
{
var s = File.OpenRead("Alarm01.wav");
var reader = new StreamReader(s, Encoding.Default);
return BitConverter.ToString(Encoding.UTF8.GetBytes(reader.ReadToEnd()));
}
Код: Выделить всё
void WriteAllBytes(string str)
{
// Step 1: Convert hex string back to UTF-8 byte array
string[] hexValues = str.Split('-');
byte[] utf8Bytes = new byte[hexValues.Length];
for (int i = 0; i < hexValues.Length; i++)
{
utf8Bytes[i] = Convert.ToByte(hexValues[i], 16);
}
// Step 2: Decode UTF-8 bytes into string
string decodedText = Encoding.UTF8.GetString(utf8Bytes);
// Step 3: Re-encode string using Encoding.Default
byte[] originalBytes = Encoding.Default.GetBytes(decodedText);
// Step 4: Write to .wav file
File.WriteAllBytes("output3.wav", originalBytes);
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... other-file