//读文件
FileStream fs = File.OpenRead("文件路径,包括扩展名"); //OpenRead
int filelength ;filelength = (int)fs.Length; //获得文件长度
byte[] image = new byte[filelength]; //建立一个字节数组
fs.Read(image, 0, filelength); //按字节流读取
string str = Convert.ToBase64String(image);//转化成Base64类型的字符串
//写文件
byte[] b = Convert.FromBase64String(str);//把字符类型转化成字节数组
System.IO.File.WriteAllBytes("文件路径,包括扩展名",b);//会覆盖原有同名文件