Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a .txt file and i have changed the file extension of this file to .exe.

Now i want to get the file extension .txt.

How is it possible. I have used below code

string extension = System.IO.Path.GetExtension(fud.PostedFile.FileName);

I am getting extension .exe but i need .txt.
Posted

C#
string myFilePath = @"C:\MyFile.txt";
string ext = Path.GetExtension(myFilePath);


use System.IO namespace
 
Share this answer
 
v2
Hi go through this-
find-out-the-real-file-type[^]
 
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