public void ScanDirectory(String path) // "C:", not "C:\" { this.mPath = path; this.PrivateClearEntries( ); // Find all files named "tetris_state_*.txt" in the directory // of the given path. if (true == Directory.Exists(path)) { String[] filePathAndNameList = Directory.GetFiles(path, "tetris_state_*.txt", SearchOption.TopDirectoryOnly); foreach (String filePathAndName in filePathAndNameList) { if (true == File.Exists(filePathAndName)) { long totalBytesInFile = 0; String fileName = ""; FileInfo fi = new FileInfo(filePathAndName); totalBytesInFile = fi.Length; fileName = fi.Name; STFileListItem item = new STFileListItem( ); item.mFileName = fileName; item.mFilePathAndName = filePathAndName; item.mFileSizeInBytes = totalBytesInFile; mListSTFileListItem.Add(item); } } } this.PrivateSortEntries( ); }
public static int Compare(Object a, Object b) { STFileListItem fa = (a as STFileListItem); STFileListItem fb = (b as STFileListItem); String sa = fa.mFileName; String sb = fb.mFileName; if ((null != sa) && (null != sb)) { return(String.Compare(sa, sb)); } return(0); }