且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是写一个简短的[]数组在C#中的文件的***方法是什么?

更新时间:2023-02-09 17:27:27

使用的BinaryWriter

Use the BinaryWriter

    static void WriteShorts(short[] values, string path)
    {
        using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
        {
            using (BinaryWriter bw = new BinaryWriter(fs))
            {
                foreach (short value in values)
                {
                    bw.Write(value);
                }
            }
        }
    }