如何找到pdf并根据用户登录打开 [英] How to find pdf and open according to user login

查看:79
本文介绍了如何找到pdf并根据用户登录打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个小型应用程序.

我有一张包含EmpID,Name和FileNo的表.

示例数据如下.

EmpID EmpName文件号
101 A 9001
102 B 9002
103 C 9003
104 D 9004


每个月我都会得到PDF文件.此文件名完全基于数据库"FileNo".

例如9001.pdf
9002.pdf ...等.

当用户单击链接按钮时,他想打开位于特定文件夹中的相应pdf文件.


例如,

当员工101时,他想打开9001.pdf.其余的应该限制打开..

单击链接按钮时如何执行此操作.

请帮助...

I am using one mini application.

I have one table which contains EmpID,Name and FileNo.

Sample data is below.

EmpID EmpName FileNo.
101 A 9001
102 B 9002
103 C 9003
104 D 9004


Every month i am getting PDF file. This file name is purely based on database "FileNo".

For Example, 9001.pdf
9002.pdf...etc..

when user clicks the link button, he wants to open his corresponding pdf file which is located in the particular folder.


For example,

When employee 101, then he wants to open 9001.pdf. the rest should restrict to open..

How to do this when i click the link button..

pls. help...

推荐答案

我给您的功能是,您只需传递文件名和带有路径的文件名,便会打开pdf文件.
您必须检查该文件是否存在.我没有在此程序中完成它
i am giving you function in which you just pass the filename and filename with path it will open the pdf file.
you have to check that this file is exist or not. i have not done it in this programm
private void OpenPDF(string sFilename,string  strPdfFileWithPath)
    {
    byte[] bytedata=System.IO.File.ReadAllBytes(strPdfFileWithPath);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", "attachment; filename=\"" + sFilename + "\"");
        Response.Flush();
        Response.BinaryWrite(bytedata);
        Response.End();
    }


这篇关于如何找到pdf并根据用户登录打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆