Home > database >  .net C# Get the extension without the dot
.net C# Get the extension without the dot

Time:08-17

i get file extension with Path.GetExtension method. But it return to me .jpg But i want only jpg

string extension=Path.GetExtension(fileName);

How can i get extension without dot ?

CodePudding user response:

Propably there is no method for this. But you can use String.Replace method after GetExtension()

string extension=Path.GetExtension(fileName).Replace(".", "");
  • Related