posts - 609,  comments - 13,  views - 64万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

复制代码
 // 使用FileStream读取文件
 using (FileStream fileStream = new FileStream(localDestZipFullName, FileMode.Open, FileAccess.Read))
 {
     // 创建一个内存流
     using (MemoryStream memoryStream = new MemoryStream())
     {
         // 将FileStream的内容复制到MemoryStream中
         fileStream.CopyTo(memoryStream);
         // 现在memoryStream包含了文件的数据,可以根据需要进行操作
         byte[] bytes = memoryStream.ToArray();
         //memoryStream.Close();
         //memoryStream.Flush();
         return File(bytes, "application/octet-stream", zipFileName);
         // 如果需要,可以将byte数组写入到其他地方,例如另一个文件
         // using (FileStream outputFile = new FileStream("output/path/to/file.txt", FileMode.Create, FileAccess.Write))
         // {
         //     outputFile.Write(data, 0, data.Length);
         // }
         // 使用内存流的代码...
     }
 }
复制代码

 

posted on   邢帅杰  阅读(42)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
历史上的今天:
2022-03-15 nacos下载、安装、使用,SpringCloud、SpringBoot、SpringCloudAlibaba版本匹配、openfeign、loadbalancer、nacos配置中心
2021-03-15 java记录
2017-03-15 mongodb学习记录
2017-03-15 记录用
2016-03-15 抽象工厂+反射
2016-03-15 单例模式
2016-03-15 利用委托机制处理.NET中的异常
点击右上角即可分享
微信分享提示