Torna al Thread
protected void Page_Load(object sender, EventArgs e)
{
ArrayList elenco = new ArrayList();
for (int i = 0; i <= 16; i++)
{
elenco.Add(i);
}
string path = Environment.GetEnvironmentVariable("TEMP") + "\\ListaNumero.xls";
string path_2=Environment.GetEnvironmentVariable("TEMP");
using (FileStream fs = File.Create(path))
{
StreamWriter sw = new StreamWriter(fs);
sw.AutoFlush = true;
StringWriter tw = new StringWriter();
tw.Write("Numeri\t\r");
foreach (int i in elenco)
{
tw.Write(i + "\t");
tw.Write("\t\r");
}
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/x-zip-compressed";
Response.AppendHeader("Content-Disposition", "attachment; filename=ArchivioNumeri.zip");
Response.Charset = "";
this.EnableViewState = false;
sw.WriteLine(tw.ToString());
sw.Flush();
sw.Close();
sw.Dispose();
System.Diagnostics.Process Proc = new System.Diagnostics.Process();
Proc.EnableRaisingEvents = false;
string pathProcesso = AppDomain.CurrentDomain.BaseDirectory;
Proc.StartInfo.FileName= @pathProcesso + "\\ZipFile.bat";
Proc.StartInfo.Arguments = "\"" + @pathProcesso + "\\pkzip25\" " + "\"" + path_2 + "\\ArchivioNumeri.zip\" \"" + path + "\"";
Proc.Start();
Response.WriteFile(path_2+"\\ArchivioNumeri.zip");
Response.Flush();
File.Delete(path);
File.Delete(path_2 + "\\ArchivioNumeri.zip");
Response.End();
}
}