Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
1.14/5 (3 votes)
See more:
Suppose I have a file Name is "Test.txt". Now if I change the extension of that file to .xls. Now my file name is "tset.xls" instead of "Test.txt". Then how can I know the file type of that file.
Posted
Updated 20-Nov-19 4:48am
Comments
Bernhard Hiller 8-Apr-13 8:18am    
No. A user who does such changes deserves error messages!

 
Share this answer
 
Hi
see you can use this

C#
string p = @"C:\Test.txt";
string e = Path.GetExtension(p);


Result : e= "txt"
 
Share this answer
 
Comments
Sumit K Sharma 16-Jun-14 8:21am    
your answer is not as per question. Because extension has changed. The question is to get file type without extension.

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