every zip file has a truncated last row. I output the row tot he console and it's not truncated, why would the last line of the compressed file be truncated?
using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connstring"]))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "final_out";
cmd.Parameters.Add("@jobid", SqlDbType.VarChar).Value = jobid;
cmd.Parameters.Add("@filename", SqlDbType.VarChar).Value = filename;
using (SqlDataReader rdr = cmd.ExecuteReader())
{
using (MemoryStream ms = new MemoryStream())
{
using (StreamWriter sw = new StreamWriter(ms))
{
while (rdr.Read())
{
string nextval = rdr[0].ToString();
sw.WriteLine(nextval);
Console.WriteLine(nextval);
}
ms.Flush();
ms.Position = 0;
using (ZipFile zf = new ZipFile(Path.Combine(Path.GetDirectoryName(finalPath), Path.GetFileNameWithoutExtension(finalPath) + ".zip")))
{
zf.AddEntry(Path.GetFileName(finalPath), ms);
zf.Save();
}
}
}
}
}
}