public StoreFile FindFile(string path, string fileName, bool subfolders)
{
StoreFolder folder = GetFolder(path);
if(folder != null) {
// check the files
int length = folder.Files.Keys.Count;
IList<string> keys = folder.Files.Keys;
for(int i = 0; i < length; i++) {
if(keys[i] == fileName) {
return files[folder.Files[fileName]];
}
}
// check in subfolders
if(subfolders) {
length = folder.Subfolders.Keys.Count;
keys = folder.Subfolders.Keys;
for(int i = 0; i < length; i++) {
StoreFile file = FindFile(path + "\\" + folder.Name, fileName, subfolders);
if(file != null) {
// file found, stop searching
return file;
}
}
}
}
// nothing found
return null;
}