【发布时间】:2015-10-21 15:36:27
【问题描述】:
我需要编写一个方法将 byte[] 转换为 .jpeg 文件,然后压缩这些 jpeg 文件。
我做了一些研究,但仍然无法弄清楚。感谢您的帮助。
代码更新
Using Ionic.Zip;
public static void ZipJpeg(int ID)
{
ZipFile zip = new ZipFile();
Dictionary<int, byte[]> photos = new Dictionary<int, byte[]>();
photos = clientInfo_BL.GetByID(ID);
string fileName;
foreach(var p in photos.Values)
{
fileName = p.uploadDate.toString() + ".jpeg";
using(Image image = image.FromStream(new MemoryStream(p.ImageData)))
{
image.Save(fileName. ImageFormat.Jpeg);
}
Zip.AddEntry(image); // couldnt figure out this one
}
zip.save()//not sure if this one is right
return zip;
}
【问题讨论】:
-
先搜索一个步骤,然后搜索另一个步骤。
-
byte[] 里面是什么?还要确保您的代码不起作用。没有魔法。看看这里stackoverflow.com/questions/8946846/… 也压缩文件只是谷歌它。 stackoverflow.com/questions/940582/…
-
感谢您的帮助。我读过的关于 zip 文件的在线帖子大多是使用文件系统来压缩文件,这不是我想要的。我希望在不使用文件系统的情况下将带有 jpeg 文件的 zip 文件返回给用户。