c# – 无法将类型为’System.Byte []’的对象强制转换为’System.IConvertible’

FMT fmt=new FMT();    

public void ReadFmtHeader()
{
    fmt.s_Sub_Chunk_ID_1 = reader.ReadBytes(4);
    fmt.ui_Sub_Chunk_Size_ID_1 = reader.ReadBytes(4);
    fmt.us_Audio_Format = reader.ReadBytes(2);
    fmt.us_Num_Channels = reader.ReadBytes(2);
    fmt.ui_Sample_Rate = reader.ReadBytes(4);
    fmt.ui_Byte_Rate = reader.ReadBytes(4);
    fmt.us_Block_Align = reader.ReadBytes(2);
    fmt.us_Bits_Per_Sample = reader.ReadBytes(2);

    if (Convert.ToInt32(fmt.ui_Sub_Chunk_Size_ID_1) == 18)// Exception thrown on this line
    {
        // Read any extra values
        int fmtExtraSize = reader.ReadInt16();
        reader.ReadBytes(fmtExtraSize);
    }
}

我正在尝试读取波形文件,然后使用标题信息重新创建它并保存到文件.
我不知道是什么问题.任何人都可以帮我吗?

解决方法

你不能使用Convert.ToInt32将byte []转换为int;你需要 use a BitConverter.

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...