日期:2014-05-17  浏览次数:20873 次

C# 提示不是所有路径都有返回值
public string GetFileType(string FileDirectory)
        {
            DirectoryInfo DI = new DirectoryInfo(FileDirectory);
            FileSystemInfo[] f = DI.GetFileSystemInfos();
            string Ex="";
            foreach (FileSystemInfo i in f)
            {
                if (i is DirectoryInfo)
                {
                    if ((i.Attributes & FileAttributes.Hidden) == 0)
                    {
                        Search(i.FullName);
                        return null;
                    }

                }
                else
                {
                    if (Ex != "")
                    {
                        Ex = i.Extension;
                        return Ex;
                    }
                    else
                    {
                        Ex = Ex + "," + i.Extension;
                        return Ex;
                    }


                }
            }
            
        }


这段