Click here to Skip to main content
15,917,582 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how can i get the extension of file
Posted
Comments
joshrduncan2012 11-Mar-14 9:36am    
What file?
Prasad Khandekar 11-Mar-14 9:39am    
Hello Kanan,

Please have a look at this tutorial. (GetExtension)

Regards,
kanan gandhi 11-Mar-14 9:55am    
i got the extension of file by using solution 1.

C#
FileInfo f = new FileInfo("pathtofile.txt");
string ext = f.Extension; //returns txt
 
Share this answer
 
VB
using System.IO;

...

Dim fileName As String = "C:\mydir.old\myfile.ext"
Dim extension As String

extension = Path.GetExtension(fileName)


See Path.GetExtension Method[^]
 
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