日期:2014-05-19  浏览次数:20851 次

如何判断一个文件是否具备后缀名?
C:\   下有个   ntldr   文件,没有后缀名导致我的程序出错,请问如何判断某文件是否具备后缀名,或者提供其他方法?

foreach(string   s   in   System.Data.Directory.GetFiles(路径))
{
        if(GetSuffixName(s))
        {
             
        }
}

private   string   GetSuffixName(string   FullFileName)
{
        int   i   =   FullFileName.LastIndexOf( ". ");
        return   FullFileName.SubString(i);//该行发生错误,因为遇到了   ntdlr   文件,该文件没有后缀名。
}

------解决方案--------------------
.IndexOf( '. ')!=-1