Cómo leer los datos binarios largos en Access. El formato de datos binarios largos es el formato PDF.
urgentemente urgentemente
El siguiente es un ejemplo de C# leyendo un registro con datos binarios
Se puede manejar de esta manera, cree un controlador de eventos llamado Attachdownload.ashx,
llamar El método es Attachdownload.ashx?AID=número de registro;
Código backend (los datos se leen en modo LINQ TO SQL)
Clase pública Adjuntardescarga: IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Configura la configuración de respuesta
context.Response. Cache.SetCacheability (HttpCacheability.Public);
contexto.Response.BufferOutput = false;
if (!string.IsNullOrEmpty(context.Request.QueryString["AID"]))
{
//Obtener los parámetros de la página
Guid AID = new Guid(context.Request.QueryString["AID"]); p>
//Obtener el registro adjunto del anuncio
SI_Affiche Affiche = Whiteboard.GetItemByID(AID);
//Obtener el nombre del archivo en el registro
string filename = context.Server.UrlEncode(Affiche.AttachTitle);
//Obtener el tipo de archivo en el registro
string filetype = Affiche.AttachType;
{
p>
//Datos de salida
if (Affiche.Attach.Length > 0)
{
contexto.Response.Clear();
contexto.Response.Buffer = true;
contexto.Response.Charset = "utf-8";
context.Response.AppendHeader("Content-Disposition ", "attachment;filename=" + filename); //Cambiar el archivo adjunto a en línea para abrirlo en línea
context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
context.Response.ContentType = tipo de archivo;
context.Response.BinaryWrite(Affiche .Attach.ToArray());
}
}
}
}
public bool IsReusable
{
obtener
{
devolver falso;
}
}
}