Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to know how getfilename works.

If I give "image.jpeg" as the input for getfilename what should I expect as output.

Will this method open the file in binary mode?

If I give a file name without extension what output should I expect.

Can anyone suggest any article or explanation of this?

is there any method to read the file-type of a given file??/
Posted
Updated 18-Jun-13 21:44pm
v4

Since you tagged your question (also) with MFC, I am assuming you are asking about CFile::GetFileName[^]. Such method, as the documentation states, returns the name of the file associated to the CFile object.

[Update]
GetFileName does NOT provide the info you are requiring. You may use the extension of the file for guessing its type or (in jpeg case) check the magic number in the header of the file (see "C# How can I test a file is a jpeg?"[^] at Stack Overflow.
[/Update]
 
Share this answer
 
v2
Comments
P Uday kishore 13-May-13 3:19am    
That's OK.but what returns am asking filename.jpg in this it returns filename it means????

i need info about filetype reading...
MuraliChagarlamudi 13-May-13 9:03am    
I have solution for this,
1st get what is the file extension of a file
For eg if you get a extension of .doc then
if(//file extension is .doc)
{
//enter your code
}
if else(//file extension is .png)
{
//enter your code
}
Look at the documentation. It clearly states that this function returns the name of the file as a string. That is all it does, and it makes no difference what the file type is.
 
Share this 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