Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way to detect whether a file(PDF file) is PDF portfolio file in C#?
[Edit: Added for sake clarity]
It has PDF extention just like any other PDF. About PDF Portfolios[^] and Sample 1[^] - Sample 2[^]
Posted
Updated 13-Jun-11 22:28pm
v3

Using JavaScript you can use regular expression to get file extension like this:

var extens=(/[.]/.exec(myfile)) ? /[^.]+$/.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 :)
 
Share this answer
 
v4
Comments
ambarishtv 14-Jun-11 4:04am    
my +5
Uday P.Singh 14-Jun-11 12:24pm    
thanks ambarishtv, but OP wants something more..
Hi uday,

I wanted to check whether a pdf file is a pdf portfolio file
 
Share this answer
 
Comments
Uday P.Singh 14-Jun-11 4:12am    
does your file have any extension?
yesotaso 14-Jun-11 4:25am    
It is PDF extention take a look at About PDF Portfolios and Sample 1 - Sample 2
Uday P.Singh 14-Jun-11 4:30am    
then i don't think its possible by just checking the extension of the file , you have to read the contents of the file as well.
yesotaso 14-Jun-11 4:35am    
You answered what is asked, it should have been given in more detail. ^^
Dharmesh Hadiyal 12-Aug-14 5:26am    
@Uday Don't hurry to give answer. Read question carefully and than try to give answer...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900