ASP.NET - Descargar .ZIP desde ASP.NET

 
Vista:
sin imagen de perfil
Val: 9
Ha aumentado 1 puesto en ASP.NET (en relación al último mes)
Gráfica de ASP.NET

Descargar .ZIP desde ASP.NET

Publicado por irving (4 intervenciones) el 10/10/2018 21:20:57
Buenas tardes, tengo este código para descargar .zip desde asp.net mediante un botod en un datagrid pero no descargar nada, no manda error, solo no ejecuta la acción.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    Label2.Text = string.Empty; ;
    if (e.CommandName == "Download")
    {
        // Retrieve the row index stored in the 
        // CommandArgument property.
        int index = Convert.ToInt32(e.CommandArgument);
 
        // Retrieve the row that contains the button 
        // from the Rows collection.
        GridViewRow row = GridView2.Rows[index];
 
        // Add code here to add the item to the shopping cart.
 
        string repositorio = ConfigurationManager.AppSettings["RutaRepositorio"].ToString(); ;
        string nombreArchivo = GridView2.Rows[index].Cells[1].Text;
 
        string rutaArchivo = Ejecutar_spObtenerRazonSocialEmpresa(int.Parse(Session["Empresa"].ToString()))+"\\";
        // rutaArchivo = rutaArchivo + "\\" + filename.Replace(".csv", "");
        string rutaCompleta = repositorio + rutaArchivo + nombreArchivo.Replace(".csv", "") +"\\"+ nombreArchivo.Replace(".csv", ".zip");
 
        string archivo= nombreArchivo.Replace(".csv", ".zip");
 
 
        if (File.Exists(rutaCompleta))
        {
            Path.GetFileName (rutaCompleta);
            MessageBox.Show(rutaCompleta);
            Response.Clear();
 
            Response.AddHeader("Content-Disposition", "attachment; filename=" + archivo);
            MessageBox.Show( archivo);
            Response.ContentType = ("application/zip");
 
            Response.WriteFile(rutaCompleta);
            MessageBox.Show(rutaCompleta);
            Response.End();
        }
        else
        {
        //    //Opción 1
           Label2.Text = "    :::: Archivo no diponible::::";
 
        }
 
    }
 
}

AYUDA!!!!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder