首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏林德熙的博客

    C# dotnet 一个看上去还能用的二进制序列化帮助类

    binaryReader) { // 读取长度 var count = binaryReader.ReadInt32(); binaryReader) { // 先读取列表长度,然后依次读取字符串 var count = binaryReader.ReadInt32 binaryReader, int headLength) { var strByteLength = (ushort)binaryReader.ReadInt16 binaryReader) { F1 = binaryReader.ReadString(); F2 = binaryReader.ReadInt32 = new BinaryReader(memoryStream); var readList = binaryReader.ReadList<FakeBinarySerialize

    39610编辑于 2022-08-12
  • 来自专栏.NET 全栈开发专栏

    ICSharpCode.SharpZipLib.Zip 解析时报错System.NotSupportedException: No data is availa

    ;}if (entry.Name.ToLower() == "resources.arsc") {Stream strm = zipfile.GetInputStream(entry);using (BinaryReader s = new BinaryReader(strm)) {resourcesData = s.ReadBytes((int)entry.Size);}}}}}}// 解决方法using (ZipInputStream ;}if (entry.Name.ToLower() == "resources.arsc") {Stream strm = zipfile.GetInputStream(entry);using (BinaryReader s = new BinaryReader(strm)) {resourcesData = s.ReadBytes((int)entry.Size);}}}}}}以上就是ICSharpCode.SharpZipLib.Zip

    52740编辑于 2023-10-31
  • 来自专栏.NET 全栈开发专栏

    利用ICSharpCode.SharpZipLib.dll解析 出错:“Wrong Local header signature: 0xFF8”

    item.Name.ToLower() == "resources.arsc") {using (Stream strm = zipfile.GetInputStream(item)) {using (BinaryReader s = new BinaryReader(strm)) {resourcesData = s.ReadBytes((int)s.BaseStream.Length);}}}}}解决方法经过查阅资料,解决方法如下 ;}if (entry.Name.ToLower() == "resources.arsc") {Stream strm = zipfile.GetInputStream(entry);using (BinaryReader s = new BinaryReader(strm)) {resourcesData = s.ReadBytes((int)entry.Size);}}}}}}参考链接Wrong Local header

    79440编辑于 2023-10-31
  • 来自专栏呆呆敲代码的小Y 公众号

    ☀️ 学会编程入门必备 C# 最基础知识介绍—— C# 高级文件操作(文本文件的读写、二进制文件的读写、Windows 文件系统的操作)

    BinaryReader 类 BinaryWriter 类 C# Windows 文件系统的操作???? DirectoryInfo 类 FileInfo 类 前言???? BinaryReader 和 BinaryWriter 类用于二进制文件的读写。 ---- BinaryReaderBinaryReader 类用于从文件读取二进制数据。 一个 BinaryReader 对象通过向它的构造函数传递 FileStream 对象而被创建。 下表列出了 BinaryReader 类中一些常用的方法: 如需查看完整的方法列表,请访问微软的 C# 文档。 bw.Close(); // 读取文件 try { br = new BinaryReader

    1.5K30发布于 2021-08-20
  • 来自专栏python3

    3-6 读写二进制文件

    3-4 读写二进制文件 u本节学习目标: n了解二进制文件读取器/编写器 n学习建立BinaryReader类的一些主要方法 n学习建立BinaryWriter类的一些主要方法 n学习通过二进制读写操作进行图片的存储与复制 3-4-1 二进制文件读取器/编写器介绍 在读写二进制文件时,需要研究的读取器/编写器组是BinaryReader和BinaryWriter,它们都从System.Object直接派生。 建立读取器/编写器(BinaryReader和BinaryWriter)需要注意的事项有两点: n要使用 BinaryReader 和 BinaryWriter 类 n这两个对象都需要在FileStream 类BinaryReader有几个常用的方法,如表3-13所示: 表3-13 类BinaryReader的常用方法 方法 说明 Close() 关闭当前阅读器及基础流。 Read() 已重载。 小实验:建立一个BinaryReader类的一些主要方法 using System; using System.IO;   class BinaryRW {     static void Main()

    1.2K10发布于 2020-01-08
  • 来自专栏林德熙的博客

    dotnet 使用 GZipStream 压缩字符串

    MemoryStream(xx); var gZipStream = new GZipStream(memoryStream, CompressionMode.Decompress); 可以通过 BinaryReader 辅助读取 var binaryReader = new BinaryReader(gZipStream, Encoding.UTF8); str = Encoding.UTF8 .GetString(binaryReader.ReadBytes(10000));

    1.2K30发布于 2020-02-17
  • 来自专栏逍遥剑客的游戏开发

    WOW小地图生成

               {               FileStream^ fs = gcnew FileStream(filename, FileMode::Open);               BinaryReader ^ br = gcnew BinaryReader(fs);   // abort the version chunk              fs->Seek(0x10, SeekOrigin: offset, FileStream^ fs)           {               fs->Seek(offset + 8, SeekOrigin::Begin);               BinaryReader ^ br = gcnew BinaryReader(fs);   // read heights              array<short>^ heights = gcnew array<short

    1.3K30发布于 2018-05-23
  • 来自专栏繁依Fanyi 的专栏

    【C# 基础精讲】文件读取和写入

    读取二进制文件 要读取二进制文件,可以使用BinaryReader类。 string[] args) { string filePath = "binary.dat"; try { using (BinaryReader reader = new BinaryReader(File.OpenRead(filePath))) { int intValue = reader.ReadInt32 Exception ex) { Console.WriteLine("发生异常:" + ex.Message); } } } 在上述示例中,我们使用BinaryReader

    96970编辑于 2023-10-12
  • 来自专栏静默虚空的博客

    PictureForm.cs

    //FileStream fs = new FileStream(gPicFilePath, FileMode.Open, FileAccess.Read); //BinaryReader br = new BinaryReader(fs); //string str = "\r\t\r\t"; //for (uint i FileStream fs = new FileStream(gPicFilePath, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); string str = br.ReadString(); //str

    31320编辑于 2022-05-07
  • 来自专栏FreeBuf

    利用Winrm.vbs绕过白名单限制执行任意代码

    switch ($OSPointerSize) { 32 { $Session = $BinaryReader.ReadUInt32() } 64 { $ Session = $BinaryReader.ReadUInt64() } } $ScanStatus = $BinaryReader.ReadByte() do { $CharVal = $BinaryReader.ReadInt16(); $null = $StringBuilder.Append([Char] $CharVal) } () $OriginalSize = $BinaryReader.ReadInt32() $ContentRaw = $BinaryReader.ReadBytes($ContentSize (0x20)).Replace('-', '') [Bool] $ContentFiltered = $BinaryReader.ReadInt32() $BinaryReader.Close

    1.9K40发布于 2018-07-31
  • 来自专栏JadePeng的技术博客

    C# 词典数据结构设计【附demo】

    先给出两个辅助方法:             idxStream = new FileStream(idxFile, FileMode.Open);             idxReader = new BinaryReader idxStream);             dictStream = new FileStream(dictfile, FileMode.Open);             dictReader = new BinaryReader dic.dict"; /// /// 词典信息文件 /// string ifoFile = "dic.ifo"; BinaryReader idxReader; FileStream idxStream; BinaryReader dictReader; FileStream dictStream idxStream); dictStream = new FileStream(dictfile, FileMode.Open); dictReader = new BinaryReader

    96740发布于 2018-03-12
  • 来自专栏深蓝居

    WebService应用:音乐站图片上传

            return "Success";     } 客户端调用: FileStream fs = new FileStream(fileName, FileMode.Open); BinaryReader br = new BinaryReader(fs); byte[] pic=br.ReadBytes((int)fs.Length); UsingWebService.localhost.Service

    59210编辑于 2022-06-15
  • 来自专栏yl 成长笔记

    c# 读取 txt 文件中数据(int)

    int { int.TryParse(item, out int vertice); Console.Write(vertice + " "); } } } 第二种方法:BinaryReader (转换为二进制文件读取) BinaryWriter bw; BinaryReader br; string line = ""; } } bw.Close(); // 读取二进制文件 br = new BinaryReader

    7.1K60发布于 2018-09-12
  • 来自专栏yl 成长笔记

    web 上读取图片,并转化为指定格式

    webRes.GetResponseStream(); byte[] buf; // 网络流不支持查找操作,通过 response 长度, 将其转化为 byte[] 进行转换 using (BinaryReader br = new BinaryReader(webStream)) { int len = (int)(webRes.ContentLength); buf =

    70310发布于 2018-12-17
  • 来自专栏静默虚空的博客

    ParseForm.cs

    //FileStream fs = new FileStream(gFilePath, FileMode.Open, FileAccess.Read); //BinaryReader br = new BinaryReader(fs); //if (br.PeekChar() !

    28020编辑于 2022-05-07
  • 来自专栏james大数据架构

    Android实现TCP断点上传,后台C#服务实现接收

    FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader bReader = new BinaryReader(fStream); //模拟断点上传,第一次只上传 100 个字节 long FileAccess.ReadWrite); //偏移指针 fStream.Seek(npos, SeekOrigin.Begin); //从客户端的请求中获取文件流 BinaryReader bReader = new BinaryReader(Request.InputStream); try { byte[] data = new

    1.4K90发布于 2018-01-22
  • 来自专栏Dotnet9

    C#百万对象序列化深度剖析:如何在网络传输中实现速度与体积的完美平衡

    目录 本文背景 构建测试数据 方案对比 Json序列化 自定义二进制序列化 BinaryWriter\BinaryReader序列化 ProtoBuf MessagePack 总结 1. 本文将探讨自定义二进制序列化、BinaryWriter/BinaryReader、MessagePack[1]和ProtoBuf[2]等4种序列化方法,并通过比较它们的性能,为大家提供我目前认为的最佳实践指南 BinaryWriter\BinaryReader BinaryWriter 和 BinaryReader 类是用于以二进制格式写入和读取数据的类。 自定义的方式全手工操作,需要自己进行字节数组的复制,各种转换,有点原始,使用BinaryWriter\BinaryReader进行序列化操作应该二进制序列化的标准用法了。 同时,高效的组包和解包处理能力对于维持网络传输性能也是至关重要的,前者可考虑MessagePack进行压缩,后者考虑原生BinaryWriter和BinaryReader。 你有更好的方式推荐吗?

    1.1K10编辑于 2023-12-13
  • 来自专栏AhDung

    【手记】注意BinaryWriter写string的小坑——会在string前加上长度前缀length-prefixed

    遂搜索一番,发现MSDN、stackoverflow早有提到,前面多出来的字节实际上是表示string的长度,叫长度前缀(length-prefixed),据SO某答主的说法,这是供BinaryReader 所以如果流的读取方不是BinaryReader,这些长度前缀就是多余甚至是有害的,这种情况下就不能使用BinaryWriter.Write(string)方法,要写入干净的string二进制,可以这样:

    1.3K30发布于 2018-09-13
  • 来自专栏c#开发者

    Processing Binary Documents Through BizTalk Via Web Services[转]

    My code is as follows: BinaryReader r = new BinaryReader(docUpload.FileContent); byte[] docBytes

    97140发布于 2018-04-12
  • 来自专栏一个爱瞎折腾的程序猿

    使用HttpDownLoadHelper下载文件

    myFile = new FileStream(_fullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); BinaryReader br = new BinaryReader(myFile); try { _Response.AddHeader

    1.6K10发布于 2018-09-14
领券