c# .net

How to remove file extension using c#.net?

How to remove file extension using c#.net?, someone asked me to explain?

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.

remove file extension using csharp .net

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.

 

remove file extension and showing as alternate text

Post your comments / questions