We can pass SPFile.Name object into FileInfo Class and get the extension of file. It will returns “.ASPX” or “.HTML” file extension depending upon file object.
Example Code:
SPFile objFile;
string strFileExtension = new FileInfo(objFile.Name).Extension;