.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Get the extension of file in .NET

Posted By:Praveen       Posted Date: April 22, 2009    Points: 10    Category: File Operation    URL: http://www.dotnetspark.com  
 

Below code shows how to get the file extension in .NET using C# or VB.net. We may need to check the file extension to validate type of file while uploading. System.IO.Path provide GetExtension() method and will return you the extension of the input file.


C# code sample

string extension = Path.GetExtension("c:\\myFile.jpg");

in Vb.NET code example

Dim extension As String = Path.GetExtension("c:\myFile.zip")

 


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend