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.
Post your comments / questions
Recent Article
- How to decode HTML character code in c#?
- How to save the xml file to a particular location?
- How to use if else statement in c++?
- How to use godaddy domain name with another godaddy hosting account?
- Restore of database 'DATABASE' failed. (Microsoft.SqlServer.Management.RelationalEngineTasks)
- How to programmatically modifying the AppSetting value in web.config using c#?
- TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined
- How to calculate the age from jQuery ui datepicker using c#?
Related Article