当前位置:   article > 正文

C#把对象序列化成二进制文件_c# 将c 转成binary

c# 将c 转成binary

static void SaveAsBinaryFormat(object obj,string filename)
        {
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binFormat =
                                     new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

            using(System.IO.Stream fsStream = new System.IO.FileStream(filename,System.IO.FileMode.Create,
                                System.IO.FileAccess.Write,System.IO.FileShare.None))
            {
                binFormat.Serialize(fsStream, obj);
            }
        }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/325234
推荐阅读
  

闽ICP备14008679号