问题背景:
将手机通讯录备份,压缩RAR,将后缀名改为.jpg,上传至QQ相册,但是提示格式错误,以前好像QQ空间只检查后缀名,咋又检查文件格式了,不晓得怎样处理了,大神们帮帮忙~
另外,当以后需要的时候 如何下载并还原为RAR文件格式~
private static void Change()
{
System.IO.FileStream fs = new System.IO.FileStream(@"F:\C盘搬家\My Documents\Wandoujia\Backup\1.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader r = new System.IO.BinaryReader(fs);
System.IO.FileStream fs2 = new System.IO.FileStream(@"F:\C盘搬家\My Documents\Wandoujia\Backup\Backup.rar", System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader r2 = new System.IO.BinaryReader(fs2);
byte[] newfile = new byte[fs.Length + fs2.Length];
//byte[] tempbyte = Encoding.Default.GetBytes("7173");
//for (int i = 0; i < tempbyte.Length; i++)
//{
// newfile[i] = tempbyte[i];
//}
//for (int i = tempbyte.Length; i < fs.Length; i++)
//{
// newfile[i] = r.ReadByte();
//}
for (int i = 0; i < fs.Length; i++)
{
newfile[i] = r.ReadByte();
}
for (long i = fs.Length; i < fs.Length + fs2.Length; i++)
{
newfile[i] = r2.ReadByte();
}
FileStream fsout = new FileStream(@"F:\C盘搬家\My Documents\Wandoujia\Backup\Backup.jpg", System.IO.FileMode.Create, System.IO.FileAccess.Write);
System.IO.BinaryWriter wr = new BinaryWriter(fsout);
wr.Write(newfile, 0, newfile.Length);
fsout.Flush();
fsout.Close();
}
将图片加在前面就行了啊~~ 哈哈 ~