将文件转换为二进制

文件 转换 二进制
public byte[] getContent(string path)
        {
            
            System.IO.FileStream fs = new System.IO.FileStream(@path, System.IO.FileMode.Open);
            fs.Position = 0;
            byte[] content = new byte[fs.Length];
            fs.Read(content, 0, (int)fs.Length);
            fs.Close();
            return content;
        }
文件 转换 二进制

将二进制转换为文件

文件 转换 二进制
        public void save(byte[] content,string path)
        {
            System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create);
            System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
            bw.Write(content, 0, content.Length);
            bw.Close();
        }
文件 转换 二进制

数据库存取的话 就是个普通的insert,select就可以了

相关文章: