Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/04/2004, 09:10
Avatar de RootK
RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 22 años, 3 meses
Puntos: 50
Bueno... tambien se los dejo en C#

C#

Cita:
private void DownloadFile(string fname, bool forceDownload)
{
string path = fname;
string name = Path.GetFileName( path );
string ext = Path.GetExtension( path );
string type = "";

if ( ext != null )
{
switch( ext.ToLower() )
{
case ".txt":
type = "text/plain";
break;

case ".doc":
case ".rtf":
type = "Application/msword";
break;

case ".xls": type = "Application/x-msexcel";
break;
}
}

if ( forceDownload )
{
Response.AppendHeader( "content-disposition","attachment; filename=" + name );
}
if ( type != "" )
Response.ContentType = type;

Response.WriteFile( path );
Response.End();
}
Y para mandarlo a llamar:

Cita:
DownloadFile(@"c:\miarchivo.doc",true);
Saludos