c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

How to remove file extension using c#.net?

| | ASP-NET , CSharp

In this article, I will show you how to remove the file extension and just display the file name using Path.GetFileNameWithoutExtension() method. 

   string fileWithoutExtension = Path.GetFileNameWithoutExtension(FileUpload1.FileName);
   lblAlternateText.Text = fileWithoutExtension;

The debugging result showing file extension was removed from the image.

While uploading the image I needed to get the alternate text from the image. So that I wanted to remove the file extension from the image.