C#文件和字节流的转换方法
作者:永远爱好写程序 时间:2022-03-18 05:39:43
本文实例讲述了C#文件和字节流的转换方法。分享给大家供大家参考。具体实现方法如下:
1、读取文件,并转换为字节流
FileStream fs = new FileStream(filename,FileMode.Open,FileAccess.Read);
byte[] infbytes = new byte[(int)fs.Length];
fs.Read(infbytes, 0, infbytes.Length);
fs.Close();
return infbytes;
2、将字节流写入文件
FileStream fs = new FileStream("D:\inf.dlv",FileMode.Create,FileAccess.Write);
fs.Write(infbytes, 0, inf.Length);
fs.Close();
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,文件,字节流
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java中的MapStruct用法详解
2022-10-05 12:18:13
![](https://img.aspxhome.com/file/2023/4/78004_0s.png)
C#实现的24点游戏实例详解
2023-03-01 16:38:51
![](https://img.aspxhome.com/file/2023/5/104275_0s.png)
基于C#技术实现身份证识别功能
2023-10-01 14:16:26
![](https://img.aspxhome.com/file/2023/8/91358_0s.png)
C# Path类---文件路径解读
2022-05-20 05:58:47
C#实现系统休眠或静止休眠的方法
2023-12-19 01:55:29
ListView通用泛型适配器
2022-06-30 11:52:04
![](https://img.aspxhome.com/file/2023/2/97862_0s.png)
Java获取指定字符串出现次数的方法
2022-05-11 16:06:23
vista和win7在windows服务中交互桌面权限问题解决方法:穿透Session 0 隔离
2021-06-16 04:05:47
![](https://img.aspxhome.com/file/2023/0/72480_0s.png)
解决Feign获取异常信息的处理方案
2023-12-11 13:17:54
![](https://img.aspxhome.com/file/2023/7/80257_0s.jpg)
C# 多线程编程技术基础知识入门
2023-05-27 08:00:24
java8新特性-lambda表达式入门学习心得
2021-09-26 17:14:33
![](https://img.aspxhome.com/file/2023/9/76489_0s.jpg)
详解C# ConcurrentBag的实现原理
2022-11-17 02:26:05
![](https://img.aspxhome.com/file/2023/2/76422_0s.jpg)
java实现单链表、双向链表
2023-02-09 03:15:59
Java的动态绑定与双分派_动力节点Java学院整理
2021-07-14 11:18:50
Java协程编程之Loom项目实战记录
2023-10-23 17:44:06
![](https://img.aspxhome.com/file/2023/3/89613_0s.png)
C# Winform实现石头剪刀布游戏
2022-03-17 17:05:14
Spring IOC基于注解启动示例详析
2022-04-19 22:49:55
![](https://img.aspxhome.com/file/2023/9/87219_0s.jpg)
SpringMVC中Controller类数据响应的方法
2021-10-07 21:00:08
![](https://img.aspxhome.com/file/2023/0/75710_0s.png)
c# 遍历 Dictionary的四种方式
2023-04-17 13:11:10
![](https://img.aspxhome.com/file/2023/5/102205_0s.png)
详解SpringBoot多跨域请求的支持(JSONP)
2023-09-21 04:12:54
![](https://img.aspxhome.com/file/2023/0/74920_0s.png)