Click here to Skip to main content
14,382,515 members
Rate this:
Please Sign up or sign in to vote.
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 5:48am
Comments
Bernhard Hiller 8-Apr-13 8:18am
   
No. A user who does such changes deserves error messages!
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi
see you can use this

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


Result : e= "txt"
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100