C# 读写文件
来源:互联网 发布:scala 下载 linux版本 编辑:程序博客网 时间:2024/06/05 10:47
读文件到byte[]的函数:
public static bool readFile(string filePathName, out byte[] bytes) { FileStream stream = new FileStream(filePathName, FileMode.Open); bool ret = false; bytes = null; if (null != stream) { int len = (int)stream.Length; bytes = new byte[len]; int readLend = stream.Read(bytes, 0, len); stream.Flush(); stream.Close(); ret = readLend == len; } return ret; }
写byte[]到文件
private void write2File(string filePathName, byte[] bytes) { if(File.Exists(filePathName)) { File.Delete(filePathName); } FileStream stream = new FileStream(filePathName, FileMode.Create); stream.Write(bytes, 0, bytes.Length); stream.Flush(); stream.Close(); }
0 0
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- c#读写xml文件
- c#读写xml文件
- c#读写xml文件
- C#读写文件
- C# 文件读写
- C#读写xml文件
- c#读写ini文件
- C#读写INI文件
- c#读写xml文件
- C#读写xml文件
- c# 读写xml文件
- C#读写xml文件
- C#读写xml文件
- C#读写中文文件
- LeetCode 74 Search a 2D Matrix
- java中:重写与重载
- C# 读取数据库 DateTime 转 string
- linux file System inode
- 微服务架构的优势与不足
- C# 读写文件
- 虾米成长记
- Could not calculate build plan: Plugin org.apache.maven.plugins:maven-war-plugin:2.1.1 or one of its
- C++容器内存分配特点简介
- JNI 使用过程的一些问题处理。
- 七牛https网页上传base64图片出现net::ERR_INSECURE_RESPONSE
- StringBuffer
- Strophe.js连接XMPP服务器Openfire、Tigase实现Web私聊、群聊(MUC)
- hibernate Query list()的缓存问题二