public void ReadandWritePicture()
{
//开始使用流读取
FileStream fs = new FileStream("D:\\A.jpg", FileMode.Open, FileAccess.Read);
//使用流读取器,把文件流对象中的内容读取出来,转换成字符串或者其他对应的数据
BinaryReader br = new BinaryReader(fs);//二进制读取器
byte[] imgbytes = br.ReadBytes((int)fs.Length);//将流中数据读取成byte数组存入数组变量中
string textString = System.Convert.ToBase64String(imgbytes);//轉為字符串
//字符串轉為byte數組
byte[] imgb= System.Convert.FromBase64String(textString);
//存進指定目錄
System.IO.File.WriteAllBytes("D:\\B.jpg", imgb);
}
1、读指定目录的图片
2、转为byte[]
3、byte[]转为string
4、string转为byte[]
5、byte[]存在其他目录为图片
原文:https://www.cnblogs.com/CarryYou-lky/p/15196285.html