where did you populate childFiles variable?FileInfo class has a property named "Extension" inherited from FileSystemInfo class. It represents the extension part of the file, duh, :-)
调试欢乐多
FileInfo[] childFiles;
string[] extensions=new string[]{"a","aa}";
DirectoryInfo parentDir=new DirectoryInfo("/");
childFiles=parentDir.GetFiles();
foreach(FileInfo childFile in childFiles)
{ index=Array.IndexOf(extensions,childFile.Extension.ToLower());
}在childFile.Extension.ToLower()中Extension从什么地方来?代表什么?
you are a good man!(-:
注意这里
FileInfo childFile in childFiles
Extension是 FileInfo的属性。获取表示文件扩展名部分的字符串。
[Serializable]
public string Extension {get;}
[C++]
[Serializable]
public: __property String* get_Extension();
[JScript]
public
Serializable
function get Extension() : String;
属性值
包含 FileSystemInfo 扩展名的字符串。备注
Extension 属性返回 FileSystemInfo 扩展名(包括句点 (.))。例如,对于文件 c:\NewFile.txt,此属性返回“.txt”。