如何检测PDF包文件? [英] How to detect PDF Portfolio file?

查看:208
本文介绍了如何检测PDF包文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以检测文件(PDF文件)是否为C#中的PDF档案文件?

与其他任何PDF一样,它具有PDF扩展功能. 关于PDF包 [示例1 [ ^ ]-示例2 [

Is there any way to detect whether a file(PDF file) is PDF portfolio file in C#?

It has PDF extention just like any other PDF. About PDF Portfolios[^] and Sample 1[^] - Sample 2[^]

推荐答案

使用JavaScript即可使用常规代码表达式以获取文件扩展名,如下所示:

var extens =(//../.exec(myfile))吗? /[^.]+
Using JavaScript you can use regular expression to get file extension like this:

var extens=(/[.]/.exec(myfile)) ? /[^.]+


/.exec(myfile):未定义;

myfile是文件的地址或路径.这只是将字符串放在."之后. .然后,您可以使用if进行一些控制检查.像:

if(extens =="doc" || extens =="pdf")
{
//您的方法在这里
}
其他
{
alert(文件无效");
}


您也可以参考此以获得更多帮助:

http://www.coursesweb.net/javascript/check-file-type-before-upload_t [^ ]

希望对您有所帮助:)
/.exec(myfile) : undefined;

myfile is the address or the path of the file. This simply takes the part of the string after "." . Then you can place some control checks with if. Something like :

if(extens=="doc" || extens=="pdf")
{
//your method goes here
}
else
{
alert("file is invalid");
}


You can also refer to this for more help:

http://www.coursesweb.net/javascript/check-file-type-before-upload_t[^]

hope this helps :)


您好,今天,

我想检查pdf文件是否为pdf档案文件
Hi uday,

I wanted to check whether a pdf file is a pdf portfolio file


这篇关于如何检测PDF包文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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