从文件中提取C#数据到字节数组

时间:2018-08-18 13:29:31

标签: c# stream byte

任何人都可以向我解释以下代码的作用以及 为什么将尺寸减去44。

public byte[] recorded_file = new byte[1000000];
public bool recorded_first_stream;
public int recorded_file_location;  

public async void TestFile(object object_name)
{
string file_name = (string)object_name;
string full_file_name = System.IO.Path.Combine
                             (Properties.Settings.Default.wave_files_location, file_name);
if (File.Exists(full_file_name))
{
            // WaveStream fileStream = new AudioFileReader(full_file_name);

            recorded_first_stream = true;
            FileStream fs = File.Open(full_file_name, FileMode.Open,
                                                FileAccess.Read, FileShare.ReadWrite);
            recorded_file_location = (int)new System.IO.FileInfo(full_file_name).Length - 44;
            BinaryReader wave_file = new BinaryReader(fs);
            wave_file.BaseStream.Seek(44, SeekOrigin.Begin);
            byte[] wave_bytes = wave_file.ReadBytes(1000000);
            Buffer.BlockCopy(wave_bytes, 0, recorded_file, 0, wave_bytes.Length);
}

0 个答案:

没有答案