我正在使用波纹管代码下载文件。但它下载文件但不显示内容或不打开文件。文件路径不同。我的项目在不同的路径上,我从不同的路径获取文件。这些文件不存储在项目路径中。文件路径、大小、名称存储在数据库中。
Crc32 crc = new Crc32();
ZipOutputStream s = new ZipOutputStream(File.Create(
@"C:\Documents and Settings\admin\My Documents\Downloads\Evidence.zip"));
s.SetLevel(0); // 0 - store only to 9 - means best compression
FileStream fs = File.OpenRead(@"c:\boot.ini");
byte[] buffer = new byte[fs.Length];
fs.Read(buffer, 0, buffer.Length);
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string fileNamePath = Convert.ToString(ds.Tables[0].Rows[i]["EvidencePath"]);
string fileNmae = Convert.ToString(ds.Tables[0].Rows[i]["EvidenceName"]);
ZipEntry entry = new ZipEntry(ZipEntry.CleanName(@fileNmae));
entry.DateTime = DateTime.Now;
entry.Comment = "test file";
entry.ZipFileIndex = i + 1;
entry.Size = fs.Length;
//fs.Close();
crc.Reset();
crc.Update(buffer);
entry.Crc = crc.Value;
s.PutNextEntry(entry);
s.Write(buffer, 0, buffer.Length);
//Response.WriteFile(""+fileNamePath);
}
s.Finish();
s.Close();
fs.Close();
}
ShowMessageBox("Downloaded....");