string fileType = System.IO.Path.GetExtension(fileName); if (!string.IsNullOrEmpty(fileType)){ //如果扩展名不为空, //执行相关操作 }