示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            string path = context.Request.QueryString["path"];

            NetworkCredential nc = GetNetCredential4Scan();

            using (
                WindowsImpersonationContextFacade impersonationContext =
                    new WindowsImpersonationContextFacade(nc))
            {
                //context.Response.Clear();
                //context.Response.ContentType = getContentType(path);

                byte[] imageByte = File.ReadAllBytes(path);

                if (imageByte != null && imageByte.Length > 0)
                {
                    context.Response.ContentType = getContentType(path);
                    context.Response.BinaryWrite(imageByte);
                }

                //context.Response.BinaryWrite(b);
                ////context.Response.WriteFile(path);
                //context.Response.End();
            }
        }
示例#2
0
        protected void btnAktScanFile_OnClick(object sender, EventArgs e)
        {
            int idAktScan = Convert.ToInt32((sender as LinkButton).Attributes["IdAktScan"]);

            SetFileScanSelected(idAktScan);

            AktScan akt = new AktScan(idAktScan);

            NetworkCredential nc = GetNetCredential4Scan();

            using (
                WindowsImpersonationContextFacade impersonationContext =
                    new WindowsImpersonationContextFacade(nc))
            {
                string archivePath = ConfigurationManager.AppSettings["documentAktScanPath"];
                string path = Path.Combine(archivePath, akt.FileName);

                ClearScanViewSelect();
                FormClear();

                if (File.Exists(path))
                {
                    lblImgNote.Text = akt.Name;
                    string url = String.Format("{0}?path={1}", ResolveClientUrl("~/Handlers/ShowImage.ashx"), path);
                    imgAktScan.ImageUrl = url;
                    imgAktScan.CssClass = "imgNormal";

                    imgAktScan.Attributes["IdAktScan"] = idAktScan.ToString();
                    FileScanDeleteDisplay(true);
                    btnAktScanFileDelete.Attributes["IdAktScan"] = idAktScan.ToString();
                }
                else
                {
                    lblImgNote.Text = "Файл не найден!";
                }
            }
        }